Microsoft.WindowsAzure.Management.ServiceManagement.Test.FunctionalTests.ServiceManagementCmdletTestHelper.GetAzureDeployment C# (CSharp) Method

GetAzureDeployment() public method

public GetAzureDeployment ( string serviceName, string slot ) : DeploymentInfoContext
serviceName string
slot string
return Microsoft.WindowsAzure.Management.ServiceManagement.Model.DeploymentInfoContext
        public DeploymentInfoContext GetAzureDeployment(string serviceName, string slot)
        {
            GetAzureDeploymentCmdletInfo getAzureDeploymentCmdletInfo = new GetAzureDeploymentCmdletInfo(serviceName, slot);
            WindowsAzurePowershellCmdlet azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(getAzureDeploymentCmdletInfo);

            Collection<PSObject> result = azurePowershellCmdlet.Run();
            if (result.Count == 1)
            {
                return (DeploymentInfoContext)result[0].BaseObject;
            }
            return null;
        }

Usage Example

Exemplo n.º 1
0
        public static Uri GetDeploymentAndWaitForReady(string serviceName, string slot, int waitTime, int maxWaitTime)
        {
            ServiceManagementCmdletTestHelper vmPowershellCmdlets = new ServiceManagementCmdletTestHelper();

            DateTime startTime = DateTime.Now;

            while (true)
            {
                bool allReady = true;
                DeploymentInfoContext result = vmPowershellCmdlets.GetAzureDeployment(serviceName, slot);
                int    instanceNum           = result.RoleInstanceList.Count;
                bool[] isReady = new bool[instanceNum];

                for (int j = 0; j < instanceNum; j++)
                {
                    var instance = result.RoleInstanceList[j];
                    Console.WriteLine("Instance: {0}, Status: {1}", instance.InstanceName, instance.InstanceStatus);
                    isReady[j] = (instance.InstanceStatus == "ReadyRole");
                    allReady  &= isReady[j];
                }

                if (!allReady && (DateTime.Now - startTime).TotalSeconds < maxWaitTime)
                {
                    Console.WriteLine("Some roles are not ready, waiting for {0} seconds.", waitTime);
                    Thread.Sleep(waitTime * 1000);
                }
                else if (!allReady) // some roles are not ready, and time-out.
                {
                    Assert.Fail("Deployment is not ready within {0} seconds!", maxWaitTime);
                }
                else // all roles are ready
                {
                    Console.WriteLine("Result of the deployment: {0}", result.Status);
                    return(result.Url);
                }
            }
        }
ServiceManagementCmdletTestHelper