示例#1
0
        public static async Task <DeploymentGetResult> GetDeploymentResultWithPolling(AscDeployment deployment, int pollInterval = 3000)
        {
            var isRunning = true;
            DeploymentGetResult deploymentResult = null;

            while (isRunning)
            {
                deploymentResult = await DeploymentManager.GetDeployment(deployment.ResourceGroupName, deployment.DeploymentName, deployment.SubscriptionId);

                switch (deploymentResult.Deployment.Properties.ProvisioningState)
                {
                case "Accepted":
                case "Running":
                    Thread.Sleep(pollInterval);
                    break;

                case "Failed":
                case "Succeeded":
                    isRunning = false;
                    break;
                }
            }
            if (deploymentResult.Deployment.Properties.ProvisioningState == "Failed")
            {
                throw new ApplicationException("Error deploying Azure Resource. " +
                                               "RequestId: " + deploymentResult.RequestId + ", " +
                                               "Id: " + deploymentResult.Deployment.Id + ", " +
                                               "CorrelationId: " + deploymentResult.Deployment.Properties.CorrelationId);
            }
            return(deploymentResult);
        }
        public static PSResourceGroupDeployment ToPSResourceGroupDeployment(this DeploymentGetResult result, string resourceGroup)
        {
            PSResourceGroupDeployment deployment = new PSResourceGroupDeployment();

            if (result != null)
            {
                deployment = CreatePSResourceGroupDeployment(result.Deployment.Name, resourceGroup, result.Deployment.Properties);
            }

            return(deployment);
        }
示例#3
0
 public static DeploymentExtended Deployment(this DeploymentGetResult deployment)
 {
     return(deployment.Deployment);
 }