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


C# CloudService.CloudServiceProject类代码示例

本文整理汇总了C#中Microsoft.WindowsAzure.Commands.Utilities.CloudService.CloudServiceProject的典型用法代码示例。如果您正苦于以下问题:C# CloudServiceProject类的具体用法?C# CloudServiceProject怎么用?C# CloudServiceProject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CloudServiceProject类属于Microsoft.WindowsAzure.Commands.Utilities.CloudService命名空间,在下文中一共展示了CloudServiceProject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:28,代码来源:AddAzureCacheWorkerRole.cs

示例2: CacheWorkerRole180

        private static void CacheWorkerRole180(string rootPath, RoleInfo cacheRoleInfo)
        {
            // Fetch cache role information from service definition and service configuration files.
            CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null);
            WorkerRole cacheWorkerRole = cloudServiceProject.Components.GetWorkerRole(cacheRoleInfo.Name);
            RoleSettings cacheRoleSettings = cloudServiceProject.Components.GetCloudConfigRole(cacheRoleInfo.Name);

            // Add caching module to the role imports
            cacheWorkerRole.Imports = GeneralUtilities.ExtendArray<Import>(
                cacheWorkerRole.Imports,
                new Import { moduleName = Resources.CachingModuleName });

            // Enable caching Diagnostic store.
            LocalStore diagnosticStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };
            cacheWorkerRole.LocalResources = GeneralUtilities.InitializeIfNull<LocalResources>(cacheWorkerRole.LocalResources);
            cacheWorkerRole.LocalResources.LocalStorage = GeneralUtilities.ExtendArray<LocalStore>(
                cacheWorkerRole.LocalResources.LocalStorage,
                diagnosticStore);

            // Remove input endpoints.
            cacheWorkerRole.Endpoints.InputEndpoint = null;

            // Add caching configuration settings
            AddCacheConfiguration(cloudServiceProject.Components.GetCloudConfigRole(cacheRoleInfo.Name));
            AddCacheConfiguration(
                cloudServiceProject.Components.GetLocalConfigRole(cacheRoleInfo.Name),
                Resources.EmulatorConnectionString);

            cloudServiceProject.Components.Save(cloudServiceProject.Paths);
        }
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:34,代码来源:CacheConfigurationFactory.cs

示例3: 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

示例4: CacheRole180

        /// <summary>
        /// Configuration required to enable dedicated caching on a given role.
        /// </summary>
        /// <param name="rootPath">The service project root path</param>
        /// <param name="cacheRoleInfo">The cache role info</param>
        private static void CacheRole180(string rootPath, RoleInfo cacheRoleInfo)
        {
            CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null);

            if (!cloudServiceProject.Components.IsWebRole(cacheRoleInfo.Name))
            {
                CacheWorkerRole180(rootPath, cacheRoleInfo);
            }
        }
开发者ID:EmmaZhu,项目名称:azure-sdk-tools,代码行数:14,代码来源:CacheConfigurationFactory.cs

示例5: CreateLocalPackageWithNodeWorkerRoleTest

        public void CreateLocalPackageWithNodeWorkerRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
                service.AddWorkerRole(Test.Utilities.Common.Data.NodeWorkerRoleScaffoldingPath);
                service.CreatePackage(DevEnv.Local);

                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
            }
        }
开发者ID:randorfer,项目名称:azure-powershell,代码行数:11,代码来源:CsPackTests.cs

示例6: SetAzureInstancesProcess

        /// <summary>
        /// The code to run if setting azure instances
        /// </summary>
        /// <param name="roleName">The name of the role to update</param>
        /// <param name="instances">The new number of instances for the role</param>
        /// <param name="rootPath">The root path to the service containing the role</param>
        /// <returns>Role after updating instance count</returns>
        public RoleSettings SetAzureInstancesProcess(string roleName, int instances, string rootPath)
        {
            CloudServiceProject service = new CloudServiceProject(rootPath, null);
            service.SetRoleInstances(service.Paths, roleName, instances);

            if (PassThru)
            {
                SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleName);
            }

            return service.Components.GetCloudConfigRole(roleName);
        }
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:19,代码来源:SetAzureServiceProjectRole.cs

示例7: StartAzureEmulatorProcess

        public CloudServiceProject StartAzureEmulatorProcess(string rootPath)
        {
            string warning;
            string roleInformation;

            StringBuilder message = new StringBuilder();
            CloudServiceProject cloudServiceProject = new CloudServiceProject(rootPath, null);

            if (Directory.Exists(cloudServiceProject.Paths.LocalPackage))
            {
                WriteVerbose(Resources.StopEmulatorMessage);
                cloudServiceProject.StopEmulators(out warning);
                if (!string.IsNullOrEmpty(warning))
                {
                    WriteWarning(warning);
                }
                WriteVerbose(Resources.StoppedEmulatorMessage);
                string packagePath = cloudServiceProject.Paths.LocalPackage;
                WriteVerbose(string.Format(Resources.RemovePackage, packagePath));
                try
                {
                    Directory.Delete(packagePath, true);
                }
                catch (IOException)
                {
                    throw new InvalidOperationException(string.Format(Resources.FailedToCleanUpLocalPackage, packagePath));
                }
            }

            WriteVerbose(string.Format(Resources.CreatingPackageMessage, "local"));
            cloudServiceProject.CreatePackage(DevEnv.Local);

            WriteVerbose(Resources.StartingEmulator);
            cloudServiceProject.ResolveRuntimePackageUrls();
            cloudServiceProject.StartEmulators(Launch.ToBool(), Mode, out roleInformation, out warning);
            WriteVerbose(roleInformation);
            if (!string.IsNullOrEmpty(warning))
            {
                WriteWarning(warning);
            }

            WriteVerbose(Resources.StartedEmulator);
            SafeWriteOutputPSObject(
                cloudServiceProject.GetType().FullName,
                Parameters.ServiceName, cloudServiceProject.ServiceName,
                Parameters.RootPath, cloudServiceProject.Paths.RootPath);

            return cloudServiceProject;
        }
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:49,代码来源:StartAzureEmulator.cs

示例8: VerifyDisableRoleSettings

 private static void VerifyDisableRoleSettings(CloudServiceProject service)
 {
     IEnumerable<RoleSettings> settings =
         Enumerable.Concat(
             service.Components.CloudConfig.Role,
             service.Components.LocalConfig.Role);
     foreach (RoleSettings roleSettings in settings)
     {
         Assert.Equal(
             1,
             roleSettings.ConfigurationSettings
                 .Where(c => c.name == "Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" && c.value == "false")
                 .Count());
     }
 }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:15,代码来源:DisableAzureRemoteDesktopCommandTest.cs

示例9: NewAzureServiceProcess

        internal CloudServiceProject NewAzureServiceProcess(string parentDirectory, string serviceName)
        {
            // Create scaffolding structure
            //
            CloudServiceProject newService = new CloudServiceProject(parentDirectory, serviceName, null);

            SafeWriteOutputPSObject(
                newService.GetType().FullName,
                Parameters.ServiceName, newService.ServiceName,
                Parameters.RootPath, newService.Paths.RootPath
                );

            WriteVerbose(string.Format(Resources.NewServiceCreatedMessage, newService.Paths.RootPath));

            return newService;
        }
开发者ID:Indhukrishna,项目名称:azure-powershell,代码行数:16,代码来源:NewAzureServiceProject.cs

示例10: TestStartAzureService

        public void TestStartAzureService()
        {
            stopServiceCmdlet.ServiceName = serviceName;
            stopServiceCmdlet.Slot = slot;
            cloudServiceClientMock.Setup(f => f.StartCloudService(serviceName, slot));

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                files.CreateAzureSdkDirectoryAndImportPublishSettings();
                CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
                stopServiceCmdlet.ExecuteCmdlet();

                Assert.Equal<int>(0, mockCommandRuntime.OutputPipeline.Count);
                cloudServiceClientMock.Verify(f => f.StartCloudService(serviceName, slot), Times.Once());
            }
        }
开发者ID:FrankSiegemund,项目名称:azure-powershell,代码行数:16,代码来源:StartAzureServiceTests.cs

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: DisableRemoteDesktop

        public void DisableRemoteDesktop()
        {
            CloudServiceProject service = new CloudServiceProject(CommonUtilities.GetServiceRootPath(CurrentPath()), null);
            WebRole[] webRoles = service.Components.Definition.WebRole ?? new WebRole[0];
            WorkerRole[] workerRoles = service.Components.Definition.WorkerRole ?? new WorkerRole[0];

            string forwarderName = GetForwarderName(webRoles, workerRoles);
            if (forwarderName != null)
            {
                UpdateServiceConfigurations(service, forwarderName);
                service.Components.Save(service.Paths);
            }

            if (PassThru)
            {
                WriteObject(true);
            }
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:18,代码来源:DisableAzureRemoteDesktop.cs


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