• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CloudService.CloudServiceProject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CloudServiceProject类属于Microsoft.WindowsAzure.Commands.Utilities.CloudService命名空间,在下文中一共展示了CloudServiceProject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: StopAzureEmulatorProcess

        public void StopAzureEmulatorProcess()
        {
            CloudServiceProject service = new CloudServiceProject();
            WriteVerbose(Resources.StopEmulatorMessage);
            
            string warning;
            service.StopEmulators(out warning);
            if (!string.IsNullOrEmpty(warning))
            {
                WriteWarning(warning);
            }

            WriteVerbose(Resources.StoppedEmulatorMessage);

            if (PassThru.IsPresent)
            {
                WriteObject(true);
            }
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:19,代码来源:StopAzureEmulator.cs


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


示例18: GetRoleName

        /// <summary>
        /// Gets role name for the current pathif exists.
        /// </summary>
        /// <returns>The role name</returns>
        public static string GetRoleName(string rootPath, string currentPath)
        {
            bool found = false;
            string roleName = null;

            if (!(rootPath.Length >= currentPath.Length))
            {
                string difference = currentPath.Replace(rootPath, string.Empty);
                roleName = difference.Split(new char[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries).GetValue(0).ToString();
                CloudServiceProject service = new CloudServiceProject(rootPath, null);
                found = service.Components.RoleExists(roleName);
            }

            if (!found)
            {
                throw new ArgumentException(string.Format(Resources.CannotFindRole, currentPath));
            }

            return roleName;
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:24,代码来源:CommonUtilities.cs


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CloudService.PublishContext类代码示例发布时间:2022-05-26
下一篇:
C# CloudService.CloudRuntimePackage类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap