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


C# CloudService.PublishContext类代码示例

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


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

示例1: AreEqualPublishContext

        public static void AreEqualPublishContext(ServiceSettings settings, string configPath, string deploymentName, string label, string packagePath, string subscriptionId, PublishContext actual)
        {
            AreEqualServiceSettings(settings, actual.ServiceSettings);
            Assert.AreEqual<string>(configPath, actual.CloudConfigPath);
            Assert.AreEqual<string>(deploymentName, actual.DeploymentName);
            Assert.AreEqual<string>(label, actual.ServiceName);
            Assert.AreEqual<string>(packagePath, actual.PackagePath);
            Assert.AreEqual<string>(subscriptionId, actual.SubscriptionId);

            Assert.IsTrue(File.Exists(actual.CloudConfigPath));
            Assert.IsTrue(File.Exists(actual.PackagePath));
        }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:12,代码来源:AzureAssert.cs

示例2: TestDeploymentSettingsTestWithDefaultServiceSettings

        public void TestDeploymentSettingsTestWithDefaultServiceSettings()
        {
            string label = "MyLabel";
            string deploymentName = service.ServiceName;
            settings.Subscription = "TestSubscription2";
            PublishContext deploySettings = new PublishContext(
                settings,
                packagePath,
                configPath,
                label,
                deploymentName,
                rootPath);

            AzureAssert.AreEqualPublishContext(settings, configPath, deploymentName, label, packagePath, "f62b1e05-af8f-4205-8f98-325079adc155", deploySettings);
        }
开发者ID:randorfer,项目名称:azure-powershell,代码行数:15,代码来源:PublishContextTests.cs

示例3: CreatePublishContext

        private PublishContext CreatePublishContext(
            string name,
            string slot,
            string location,
            string affinityGroup,
            string storageServiceName,
            string deploymentName)
        {
            string serviceName;
            CloudServiceProject cloudServiceProject = GetCurrentServiceProject();

            // If the name provided is different than existing name change it
            if (!string.IsNullOrEmpty(name) && name != cloudServiceProject.ServiceName)
            {
                cloudServiceProject.ChangeServiceName(name, cloudServiceProject.Paths);
            }

            // If there's no storage service provided, try using the default one
            if (string.IsNullOrEmpty(storageServiceName))
            {
                storageServiceName = Subscription.CurrentStorageAccountName;
            }

            // Use default location if not location and affinity group provided
            location = string.IsNullOrEmpty(location) && string.IsNullOrEmpty(affinityGroup) ? 
                GetDefaultLocation() : 
                location;

            ServiceSettings serviceSettings = ServiceSettings.LoadDefault(
                cloudServiceProject.Paths.Settings,
                slot,
                location,
                affinityGroup,
                Subscription.SubscriptionName,
                storageServiceName,
                name,
                cloudServiceProject.ServiceName,
                out serviceName
                );

            PublishContext context = new PublishContext(
                serviceSettings,
                Path.Combine(GetCurrentDirectory(), cloudServiceProject.Paths.CloudPackage),
                Path.Combine(GetCurrentDirectory(), cloudServiceProject.Paths.CloudConfiguration),
                serviceName,
                deploymentName,
                cloudServiceProject.Paths.RootPath);

            return context;
        }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:50,代码来源:CloudServiceClient.cs

示例4: UploadPackage

        private Uri UploadPackage(PublishContext context)
        {
            WriteVerboseWithTimestamp(
                    Resources.PublishUploadingPackageMessage,
                    context.ServiceSettings.StorageServiceName);

            return CloudBlobUtility.UploadPackageToBlob(
                StorageClient,
                context.ServiceSettings.StorageServiceName,
                context.PackagePath,
                new BlobRequestOptions());
        }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:12,代码来源:CloudServiceClient.cs

示例5: GetDeploymentId

        private string GetDeploymentId(PublishContext context)
        {
            Deployment deployment = new Deployment();

            do
            {
                // If a deployment has many roles to initialize, this
                // thread must throttle requests so the Azure portal
                // doesn't reply with a "too many requests" error
                Thread.Sleep(SleepDuration);

                try
                {
                    deployment = new Deployment(
                        ComputeClient.Deployments.GetBySlot(context.ServiceName,
                        GetSlot(context.ServiceSettings.Slot)));
                }
                catch (CloudException ex)
                {
                    if (ex.Response.StatusCode != HttpStatusCode.InternalServerError)
                    {
                        throw;
                    }
                }
            }
            while (deployment.Status != DeploymentStatus.Starting && deployment.Status != DeploymentStatus.Running);

            return deployment.PrivateID;
        }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:29,代码来源:CloudServiceClient.cs

示例6: VerifyDeployment

        private void VerifyDeployment(PublishContext context)
        {
            try
            {
                WriteVerboseWithTimestamp(Resources.PublishInitializingMessage);

                var roleInstanceSnapshot = new Dictionary<string, RoleInstance>();

                // Continue polling for deployment until all of the roles
                // indicate they're ready
                Deployment deployment;
                do
                {
                    deployment = new Deployment(
                        ComputeClient.Deployments.GetBySlot(context.ServiceName, GetSlot(context.ServiceSettings.Slot)));

                    // The goal of this loop is to output a message whenever the status of a role 
                    // instance CHANGES. To do that, we have to remember the last status of all role instances
                    // and that's what the roleInstanceSnapshot array is for
                    foreach (RoleInstance currentInstance in deployment.RoleInstanceList)
                    {
                        // We only care about these three statuses, ignore other intermediate statuses
                        if (string.Equals(currentInstance.InstanceStatus, RoleInstanceStatus.BusyRole) ||
                            string.Equals(currentInstance.InstanceStatus, RoleInstanceStatus.ReadyRole) ||
                            string.Equals(currentInstance.InstanceStatus, RoleInstanceStatus.CreatingRole))
                        {
                            bool createdOrChanged = false;

                            // InstanceName is unique and concatenates the role name and instance name
                            if (roleInstanceSnapshot.ContainsKey(currentInstance.InstanceName))
                            {
                                // If we already have a snapshot of that role instance, update it
                                RoleInstance previousInstance = roleInstanceSnapshot[currentInstance.InstanceName];
                                if (!string.Equals(previousInstance.InstanceStatus, currentInstance.InstanceStatus))
                                {
                                    // If the instance status changed, we need to output a message
                                    previousInstance.InstanceStatus = currentInstance.InstanceStatus;
                                    createdOrChanged = true;
                                }
                            }
                            else
                            {
                                // If this is the first time we run through, we also need to output a message
                                roleInstanceSnapshot[currentInstance.InstanceName] = currentInstance;
                                createdOrChanged = true;
                            }

                            if (createdOrChanged)
                            {
                                string statusResource;
                                switch (currentInstance.InstanceStatus)
                                {
                                    case RoleInstanceStatus.BusyRole:
                                        statusResource = Resources.PublishInstanceStatusBusy;
                                        break;

                                    case RoleInstanceStatus.ReadyRole:
                                        statusResource = Resources.PublishInstanceStatusReady;
                                        break;

                                    default:
                                        statusResource = Resources.PublishInstanceStatusCreating;
                                        break;
                                }

                                WriteVerboseWithTimestamp(
                                    Resources.PublishInstanceStatusMessage,
                                    currentInstance.InstanceName,
                                    currentInstance.RoleName,
                                    statusResource);
                            }
                        }
                    }

                    // If a deployment has many roles to initialize, this
                    // thread must throttle requests so the Azure portal
                    // doesn't reply with a "too many requests" error
                    Thread.Sleep(SleepDuration);
                }
                while (deployment.RoleInstanceList.Any(r => r.InstanceStatus != RoleInstanceStatus.ReadyRole));

                WriteVerboseWithTimestamp(Resources.PublishCreatedWebsiteMessage, deployment.Url);

            }
            catch (CloudException)
            {
                throw new InvalidOperationException(
                    string.Format(Resources.CannotFindDeployment, context.ServiceName, context.ServiceSettings.Slot));
            }
        }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:90,代码来源:CloudServiceClient.cs

示例7: UpgradeDeployment

        private void UpgradeDeployment(PublishContext context)
        {
            var upgradeParams = new DeploymentUpgradeParameters
            {
                Configuration = General.GetConfiguration(context.ConfigPath),
                PackageUri = UploadPackage(context),
                Label = context.ServiceName,
                Mode = DeploymentUpgradeMode.Auto
            };

            WriteVerboseWithTimestamp(Resources.PublishUpgradingMessage);

            var uploadedCertificates = ComputeClient.ServiceCertificates.List(context.ServiceName);
            AddCertificates(uploadedCertificates, context);

            ComputeClient.Deployments.UpgradeBySlot(context.ServiceName, GetSlot(context.ServiceSettings.Slot), upgradeParams);
        }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:17,代码来源:CloudServiceClient.cs

示例8: AreEqualDeploymentSettings

 public static void AreEqualDeploymentSettings(PublishContext expected, PublishContext actual)
 {
     AreEqualPublishContext(expected.ServiceSettings, expected.CloudConfigPath, expected.DeploymentName, expected.ServiceName, expected.PackagePath, expected.SubscriptionId, actual);
 }
开发者ID:hovsepm,项目名称:azure-sdk-tools,代码行数:4,代码来源:AzureAssert.cs

示例9: TestDeploymentSettingsTestNullLabelFail

        public void TestDeploymentSettingsTestNullLabelFail()
        {
            string deploymentName = service.ServiceName;

            try
            {
                PublishContext deploySettings = new PublishContext(
                    settings,
                    packagePath,
                    configPath,
                    null,
                    deploymentName,
                    rootPath);
                Assert.True(false, "No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.True(ex is ArgumentException);
                Assert.True(string.Compare(
                    string.Format(Resources.InvalidOrEmptyArgumentMessage,
                    "serviceName"), ex.Message, true) == 0);
            }
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:23,代码来源:PublishContextTests.cs

示例10: UpdateCacheWorkerRolesCloudConfiguration

        private void UpdateCacheWorkerRolesCloudConfiguration(PublishContext context)
        {
            string connectionString = GetStorageServiceConnectionString(context.ServiceSettings.StorageServiceName);
            var cloudServiceProject = new CloudServiceProject(context.RootPath, null);

            var connectionStringConfig = new ConfigConfigurationSetting
            {
                name = Resources.CachingConfigStoreConnectionStringSettingName,
                value = string.Empty
            };

            cloudServiceProject.Components.ForEachRoleSettings(
                r => Array.Exists(r.ConfigurationSettings, c => c.Equals(connectionStringConfig)),
                r =>
                    {
                        int index = Array.IndexOf(r.ConfigurationSettings, connectionStringConfig);
                        r.ConfigurationSettings[index] = new ConfigConfigurationSetting
                        {
                            name = Resources.CachingConfigStoreConnectionStringSettingName,
                            value = connectionString
                        };
                    });

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

示例11: PrepareCloudServicePackagesRuntime

        private void PrepareCloudServicePackagesRuntime(PublishContext context)
        {
            CloudServiceProject cloudServiceProject = new CloudServiceProject(context.RootPath, null);
            string warning = cloudServiceProject.ResolveRuntimePackageUrls();

            if (!string.IsNullOrEmpty(warning))
            {
                WriteWarning(Resources.RuntimeMismatchWarning, context.ServiceName);
                WriteWarning(warning);
            }
        }
开发者ID:ranjitk9,项目名称:azure-sdk-tools,代码行数:11,代码来源:CloudServiceClient.cs

示例12: DeployPackage

        private DeploymentGetResponse DeployPackage(bool launch, bool forceUpgrade, PublishContext context)
        {
            // Publish cloud service
            WriteVerboseWithTimestamp(Resources.PublishConnectingMessage);
            CreateCloudServiceIfNotExist(
                context.ServiceName,
                affinityGroup: context.ServiceSettings.AffinityGroup,
                location: context.ServiceSettings.Location);

            if (DeploymentExists(context.ServiceName, context.ServiceSettings.Slot))
            {
                // Upgrade the deployment
                UpgradeDeployment(context, forceUpgrade);
            }
            else
            {
                // Create new deployment
                CreateDeployment(context);
            }

            // Get the deployment id and show it.
            WriteVerboseWithTimestamp(Resources.PublishCreatedDeploymentMessage, GetDeploymentId(context));

            // Verify the deployment succeeded by checking that each of the roles are running
            VerifyDeployment(context);

            // Get object of the published deployment
            DeploymentGetResponse deployment = ComputeClient.Deployments.GetBySlot(context.ServiceName, GetSlot(context.ServiceSettings.Slot));

            if (launch)
            {
                GeneralUtilities.LaunchWebPage(deployment.Uri.ToString());
            }
            return deployment;
        }
开发者ID:kangyangthu,项目名称:azure-sdk-tools,代码行数:35,代码来源:CloudServiceClient.cs

示例13: SetupStorageService

        private void SetupStorageService(PublishContext context)
        {
            WriteVerboseWithTimestamp(
                Resources.PublishVerifyingStorageMessage,
                context.ServiceSettings.StorageServiceName);

            CreateStorageServiceIfNotExist(
                context.ServiceSettings.StorageServiceName,
                context.ServiceName,
                context.ServiceSettings.Location,
                context.ServiceSettings.AffinityGroup);
        }        
开发者ID:kangyangthu,项目名称:azure-sdk-tools,代码行数:12,代码来源:CloudServiceClient.cs

示例14: UploadPackageIfNeeded

 private Uri UploadPackageIfNeeded(PublishContext context)
 {
     Uri packageUri;
     if (context.PackageIsFromStorageAccount)
     {
         packageUri = new Uri(context.PackagePath);
     }
     else
     {
         packageUri = UploadPackage(context);
     }
     return packageUri;
 }
开发者ID:kangyangthu,项目名称:azure-sdk-tools,代码行数:13,代码来源:CloudServiceClient.cs

示例15: TestDeploymentSettingsTestNullSettingsFail

        public void TestDeploymentSettingsTestNullSettingsFail()
        {
            string label = "MyLabel";
            string deploymentName = service.ServiceName;

            try
            {
                PublishContext deploySettings = new PublishContext(
                    null,
                    packagePath,
                    configPath,
                    label,
                    deploymentName,
                    rootPath);
                Assert.True(false, "No exception was thrown");
            }
            catch (Exception ex)
            {
                Assert.True(ex is ArgumentException);
                Assert.Equal<string>(Resources.InvalidServiceSettingMessage, ex.Message);
            }
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:22,代码来源:PublishContextTests.cs


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