예제 #1
0
 static void Main(string[] args)
 {
     string[] myCommands = new string[]
     {
         //List VM
         "/subscriptions/{0}/providers/Microsoft.Compute/virtualMachines?api-version=2016-04-30-preview",
         //List Public IPs
         "subscriptions/{0}/providers/Microsoft.Network/publicIPAddresses?api-version=2016-09-01",
         //List Public IP on RG ARMD-636238979770432643
         "subscriptions/{0}/resourceGroups/ARMD-636238979770432643/providers/Microsoft.Network/publicIPAddresses?api-version=2016-09-01"
     };
     //Read configuration
     setup();
     //Get token
     _myToken = myTokenManager.GetToken(_tenant_id, _client_id, _client_secret, _managementUrl, _loginUrl).Result;
     //listing resources and Print
     foreach (string myCommand in myCommands)
     {
         string currentCommand = string.Format(myCommand, _subscription_id);
         string json           = myTokenManager.ExecuteGet(currentCommand, _managementUrl, _myToken).Result;
         PrintJsonData(json);
         Console.ReadLine();
         Console.Clear();
     }
 }
예제 #2
0
        /// <summary>
        /// Wait until deploy change to status Succeded
        /// </summary>
        /// <param name="RGName">Resource Group Name</param>
        /// <param name="DeployName">Deployment Name</param>
        static void waitDeploy(string RGName, string DeployName)
        {
            string command = String.Format(
                "subscriptions/{0}/resourcegroups/{1}/providers/Microsoft.Resources/deployments/{2}?api-version=2016-09-01",
                _subscription_id,
                RGName,
                DeployName
                );

            string provisioningState = "";

            while (provisioningState != "Succeeded")
            {
                var     rString    = myTokenManager.ExecuteGet(command, _managementUrl, _myToken).Result;
                JObject myResponse = JObject.Parse(rString);
                provisioningState = myResponse.SelectToken("properties").SelectToken("provisioningState").ToString();

                Console.WriteLine("{1} provisioningState: {0}", provisioningState, RGName);

                System.Threading.Thread.Sleep(5 * 1000);
            }
            Console.WriteLine("");
        }