本文整理汇总了C#中Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject.AddWebRole方法的典型用法代码示例。如果您正苦于以下问题:C# CloudServiceProject.AddWebRole方法的具体用法?C# CloudServiceProject.AddWebRole怎么用?C# CloudServiceProject.AddWebRole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject
的用法示例。
在下文中一共展示了CloudServiceProject.AddWebRole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteCmdlet
public override void ExecuteCmdlet()
{
RootPath = RootPath ?? CommonUtilities.GetServiceRootPath(CurrentPath());
CloudServiceProject service = new CloudServiceProject(RootPath, null);
RoleInfo roleInfo = null;
if (isWebRole)
{
roleInfo = service.AddWebRole(Scaffolding, Name, Instances);
}
else
{
roleInfo = service.AddWorkerRole(Scaffolding, Name, Instances);
}
OnProcessing(roleInfo);
try
{
service.ChangeRolePermissions(roleInfo);
SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleInfo.Name);
WriteVerbose(string.Format(successMessage, RootPath, roleInfo.Name));
}
catch (UnauthorizedAccessException)
{
WriteWarning(Resources.AddRoleMessageInsufficientPermissions);
}
}
示例2: CreateCloudPackageWithMultipleRoles
public void CreateCloudPackageWithMultipleRoles()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Test.Utilities.Common.Data.NodeWorkerRoleScaffoldingPath);
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
service.AddWorkerRole(Test.Utilities.Common.Data.PHPWorkerRoleScaffoldingPath);
service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath);
service.CreatePackage(DevEnv.Cloud);
using (Package package = Package.Open(service.Paths.CloudPackage))
{
Assert.Equal(9, package.GetParts().Count());
}
}
}
示例3: CreateLocalPackageWithMultipleRoles
public void CreateLocalPackageWithMultipleRoles()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWorkerRole(Test.Utilities.Common.Data.NodeWorkerRoleScaffoldingPath);
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
service.AddWorkerRole(Test.Utilities.Common.Data.PHPWorkerRoleScaffoldingPath);
service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath);
service.CreatePackage(DevEnv.Local);
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));
}
}
示例4: CreateLocalPackageWithOnePHPWebRoleTest
public void CreateLocalPackageWithOnePHPWebRoleTest()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
RoleInfo webRoleInfo = service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath);
string logsDir = Path.Combine(service.Paths.RootPath, webRoleInfo.Name, "server.js.logs");
string logFile = Path.Combine(logsDir, "0.txt");
string targetLogsFile = Path.Combine(service.Paths.LocalPackage, "roles", webRoleInfo.Name, @"approot\server.js.logs\0.txt");
files.CreateDirectory(logsDir);
files.CreateEmptyFile(logFile);
service.CreatePackage(DevEnv.Local);
AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WebRole));
Assert.True(File.Exists(targetLogsFile));
}
}
示例5: SetAzureVMSizeProcessTestsNode
public void SetAzureVMSizeProcessTestsNode()
{
string newRoleVMSize = "Large";
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
string roleName = "WebRole1";
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
cmdlet.PassThru = false;
RoleSettings roleSettings = cmdlet.SetAzureVMSizeProcess("WebRole1", newRoleVMSize, service.Paths.RootPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
Assert.Equal<string>(newRoleVMSize, service.Components.Definition.WebRole[0].vmsize.ToString());
Assert.Equal<int>(0, mockCommandRuntime.OutputPipeline.Count);
Assert.Equal<string>(roleName, roleSettings.name);
}
}
示例6: TestSetAzureRuntimeValidRuntimeVersions
public void TestSetAzureRuntimeValidRuntimeVersions()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
string roleName = "WebRole1";
cmdlet.PassThru = false;
RoleSettings roleSettings1 = cmdlet.SetAzureRuntimesProcess(roleName, "node", "0.8.2", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files));
RoleSettings roleSettings2 = cmdlet.SetAzureRuntimesProcess(roleName, "iisnode", "0.1.21", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files));
VerifyPackageJsonVersion(service.Paths.RootPath, roleName, "node", "0.8.2");
VerifyPackageJsonVersion(service.Paths.RootPath, roleName, "iisnode", "0.1.21");
Assert.Equal<int>(0, mockCommandRuntime.OutputPipeline.Count);
Assert.Equal<string>(roleName, roleSettings1.name);
Assert.Equal<string>(roleName, roleSettings2.name);
}
}
示例7: SetAzureVMSizeProcessTestsPHP
public void SetAzureVMSizeProcessTestsPHP()
{
string newRoleVMSize = "Medium";
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
string roleName = "WebRole1";
service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath);
RoleSettings roleSettings = cmdlet.SetAzureVMSizeProcess("WebRole1", newRoleVMSize, service.Paths.RootPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
Assert.Equal<string>(newRoleVMSize, service.Components.Definition.WebRole[0].vmsize.ToString());
Assert.Equal<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).Members[Parameters.RoleName].Value.ToString());
Assert.True(((PSObject)mockCommandRuntime.OutputPipeline[0]).TypeNames.Contains(typeof(RoleSettings).FullName));
Assert.Equal<string>(roleName, roleSettings.name);
}
}
示例8: TestCreatePackageSuccessfull
public void TestCreatePackageSuccessfull()
{
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(@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Services"));
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
cmdlet.ExecuteCmdlet();
PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject;
Assert.Equal<string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]);
Assert.Equal<string>(packagePath, obj.GetVariableValue<string>(Parameters.PackagePath));
Assert.True(File.Exists(packagePath));
}
}
示例9: SetAzureInstancesProcessTestsNode
public void SetAzureInstancesProcessTestsNode()
{
int newRoleInstances = 10;
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
string roleName = "WebRole1";
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
cmdlet.PassThru = false;
RoleSettings roleSettings = cmdlet.SetAzureInstancesProcess("WebRole1", newRoleInstances, service.Paths.RootPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
Assert.Equal<int>(newRoleInstances, service.Components.CloudConfig.Role[0].Instances.count);
Assert.Equal<int>(newRoleInstances, service.Components.LocalConfig.Role[0].Instances.count);
Assert.Equal<int>(0, mockCommandRuntime.OutputPipeline.Count);
Assert.Equal<int>(newRoleInstances, roleSettings.Instances.count);
Assert.Equal<string>(roleName, roleSettings.name);
}
}
示例10: 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(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath);
service.Components.Definition.WebRole.ToList().ForEach(wr => wr.Endpoints = null);
service.AddWorkerRole(Test.Utilities.Common.Data.PHPWorkerRoleScaffoldingPath);
service = new CloudServiceProject(service.Paths.RootPath, null);
int nextPort = service.Components.GetNextPort();
Assert.Equal<int>(expectedPort, nextPort);
}
}
示例11: AzureServiceAddExistingPHPRoleFail
public void AzureServiceAddExistingPHPRoleFail()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath, "WebRole");
Testing.AssertThrows<ArgumentException>(() => service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath, "WebRole"), string.Format(Resources.AddRoleMessageRoleExists, "WebRole"));
}
}
示例12: SetPHPRoleInstancesTest
public void SetPHPRoleInstancesTest()
{
int newInstances = 10;
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath, "WebRole", 1);
service.SetRoleInstances(service.Paths, "WebRole", newInstances);
Assert.Equal<int>(service.Components.CloudConfig.Role[0].Instances.count, newInstances);
Assert.Equal<int>(service.Components.LocalConfig.Role[0].Instances.count, newInstances);
}
}
示例13: SetAzureServiceProjectRoleInDeepDirectory
public void SetAzureServiceProjectRoleInDeepDirectory()
{
TestMockSupport.TestExecutionFolder = AppDomain.CurrentDomain.BaseDirectory;
string serviceName = "AzureService2";
if (Directory.Exists(Path.Combine(TestMockSupport.TestExecutionFolder, serviceName)))
{
Directory.Delete(Path.Combine(TestMockSupport.TestExecutionFolder, serviceName), true);
}
CloudServiceProject service = new CloudServiceProject(TestMockSupport.TestExecutionFolder, serviceName, null);
service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
TestMockSupport.TestExecutionFolder = Path.Combine(service.Paths.RootPath, "WebRole1", "bin");
cmdlet.RoleName = string.Empty;
cmdlet.ExecuteCmdlet();
service = new CloudServiceProject(service.Paths.RootPath, null);
Assert.Equal<string>("WebRole1", cmdlet.RoleName);
}
示例14: AzureServiceAddNewPHPWebRoleTest
public void AzureServiceAddNewPHPWebRoleTest()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
RoleInfo webRole = service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath, "MyWebRole", 10);
AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName, webRoles: new WebRoleInfo[] { (WebRoleInfo)webRole }, webScaff: Path.Combine(Resources.PHPScaffolding, Resources.WebRole), roles: new RoleInfo[] { webRole });
}
}
示例15: TestPublishWithDefaultLocation
public void TestPublishWithDefaultLocation()
{
RemoveDeployments();
clientMocks.ComputeManagementClientMock.Setup(
c =>
c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>()))
.Returns(Tasks.FromResult(new OperationResponse
{
RequestId = "request001",
StatusCode = HttpStatusCode.OK
}));
clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny<CancellationToken>()))
.Returns(Tasks.FromResult(new LocationsListResponse
{
Locations =
{
new LocationsListResponse.Location {DisplayName = "East US", Name = "EastUS"}
}
}));
using (var files = new FileSystemHelper(this) { EnableMonitoring = true })
{
// Setup
string rootPath = files.CreateNewService(serviceName);
files.CreateAzureSdkDirectoryAndImportPublishSettings();
var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services"));
cloudServiceProject.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath);
ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService());
clientMocks.ManagementClientMock.Verify(c => c.Locations.ListAsync(It.IsAny<CancellationToken>()), Times.Once);
}
}