当前位置: 首页>>代码示例>>C#>>正文


C# CloudServiceProject.AddWebRole方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:28,代码来源:AddRole.cs

示例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());
                }
            }
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:17,代码来源:CsPackTests.cs

示例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));
            }
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:17,代码来源:CsPackTests.cs

示例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));
            }
        }
开发者ID:randorfer,项目名称:azure-powershell,代码行数:17,代码来源:CsPackTests.cs

示例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);
            }
        }
开发者ID:Indhukrishna,项目名称:azure-powershell,代码行数:18,代码来源:SetAzureVMSizeTests.cs

示例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);
     }
 }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:18,代码来源:SetAzureRuntimeTests.cs

示例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);
            }
        }
开发者ID:Indhukrishna,项目名称:azure-powershell,代码行数:19,代码来源:SetAzureVMSizeTests.cs

示例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));
            }
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:20,代码来源:SaveAzureServiceProjectPackageTests.cs

示例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);

            }
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:21,代码来源:SetAzureInstancesTests.cs

示例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);
     }
 }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:14,代码来源:ServiceComponentsTests.cs

示例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"));
     }
 }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:9,代码来源:AzureServiceTests.cs

示例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);
            }
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:13,代码来源:AzureServiceTests.cs

示例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);
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:17,代码来源:SetAzureInstancesTests.cs

示例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 });
            }
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:10,代码来源:AzureServiceTests.cs

示例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);
            }
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:35,代码来源:CloudServiceClientTests.cs


注:本文中的Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject.AddWebRole方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。