本文整理汇总了C#中CloudServiceProject.AddWorkerRole方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServiceProject.AddWorkerRole方法的具体用法?C# CloudServiceProject.AddWorkerRole怎么用?C# CloudServiceProject.AddWorkerRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CloudServiceProject
的用法示例。
在下文中一共展示了CloudServiceProject.AddWorkerRole方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAzureCacheWorkerRoleProcess
public WorkerRole AddAzureCacheWorkerRoleProcess(string workerRoleName, int instances, string rootPath)
{
// Create cache worker role.
Action<string, RoleInfo> cacheWorkerRoleAction = CacheConfigurationFactory.GetCacheRoleConfigurationAction(
AzureTool.GetAzureSdkVersion());
CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null);
RoleInfo genericWorkerRole = cloudServiceProject.AddWorkerRole(
Path.Combine(Resources.GeneralScaffolding, RoleType.WorkerRole.ToString()),
workerRoleName,
instances);
// Dedicate the worker role for caching.
cacheWorkerRoleAction(cloudServiceProject.Paths.RootPath, genericWorkerRole);
cloudServiceProject.Reload();
WorkerRole cacheWorkerRole = cloudServiceProject.Components.GetWorkerRole(genericWorkerRole.Name);
// Write output
SafeWriteOutputPSObject(
cacheWorkerRole.GetType().FullName,
Parameters.CacheWorkerRoleName, genericWorkerRole.Name,
Parameters.Instances, genericWorkerRole.InstanceCount
);
return cloudServiceProject.Components.GetWorkerRole(workerRoleName);
}
示例2: CreateLocalPackageWithNodeWorkerRoleTest
public void CreateLocalPackageWithNodeWorkerRoleTest()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service.CreatePackage(DevEnv.Local);
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
}
}
示例3: SetAzureVMSizeProcessTestsPHPRoleNameDoesNotExistServiceContainsWorkerRoleFail
public void SetAzureVMSizeProcessTestsPHPRoleNameDoesNotExistServiceContainsWorkerRoleFail()
{
string roleName = "WorkerRole1";
string invalidRoleName = "foo";
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath, roleName, 1);
Testing.AssertThrows<ArgumentException>(() => service.SetRoleVMSize(service.Paths, invalidRoleName, RoleSize.Large.ToString()), string.Format(Resources.RoleNotFoundMessage, invalidRoleName));
}
}
示例4: GetNextPortNullPHPWebEndpointAndWorkerRole
public void GetNextPortNullPHPWebEndpointAndWorkerRole()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
int expectedPort = int.Parse(Resources.DefaultPort);
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
service.Components.Definition.WebRole.ToList().ForEach(wr => wr.Endpoints = null);
service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
int nextPort = service.Components.GetNextPort();
Assert.AreEqual<int>(expectedPort, nextPort);
}
}
示例5: GetNextPortNodeWebRoleNull
public void GetNextPortNodeWebRoleNull()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
int expectedPort = int.Parse(Resources.DefaultPort);
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
int nextPort = service.Components.GetNextPort();
Assert.AreEqual<int>(expectedPort, nextPort);
}
}
示例6: CreateCloudPackageWithMultipleRoles
public void CreateCloudPackageWithMultipleRoles()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath);
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
service.CreatePackage(DevEnv.Cloud);
using (Package package = Package.Open(service.Paths.CloudPackage))
{
Assert.AreEqual(9, package.GetParts().Count());
}
}
}
示例7: TestCreatePackageWithMultipleRolesSuccessfull
public void TestCreatePackageWithMultipleRolesSuccessfull()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
files.CreateAzureSdkDirectoryAndImportPublishSettings();
files.CreateNewService("NEW_SERVICE");
string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE");
string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName);
CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services"));
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
cmdlet.ExecuteCmdlet();
PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject;
Assert.AreEqual<string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]);
Assert.AreEqual<string>(packagePath, obj.GetVariableValue<string>(Parameters.PackagePath));
Assert.IsTrue(File.Exists(packagePath));
}
}
示例8: AzureServiceAddNewPHPWorkerRoleTest
public void AzureServiceAddNewPHPWorkerRoleTest()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
RoleInfo workerRole = service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath, "MyWorkerRole", 10);
AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName, workerRoles: new WorkerRoleInfo[] { (WorkerRoleInfo)workerRole }, workerScaff: Path.Combine(Resources.PHPScaffolding, Resources.WorkerRole), roles: new RoleInfo[] { workerRole });
}
}
示例9: CreateLocalPackageWithMultipleRoles
public void CreateLocalPackageWithMultipleRoles()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string standardOutput;
string standardError;
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath);
service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
service.CreatePackage(DevEnv.Local, out standardOutput, out standardError);
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WebRole));
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole2\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WorkerRole));
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole2\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WebRole));
}
}