How to find out the results of Azure Management calls when using REST APIs

Recently, I got the following question: How can we find out the result of some Azure Management call when using REST API.

For this sample, we will use REST API to increase the number of cores for the deployment.

All REST API calls are asynchronous. This means that as soon as the initial call is accepted by the server, the server returns 202.

If you want to know the status of executing that request, then you have to make get-operationstatus call with the operation ID of the previous call.

The correct process to increase the number of cores using REST API would be:

1.Make a POST call to change deployment configuration to increase the number of cores:
The Change Deployment Configuration is documented at https://msdn.microsoft.com/en-us/library/ee460809.aspx
Example: https://management.core.windows.net/<subscription-id>/services/hostedservices/<cloudservice-name>/deploymentslots/<deployment-slot>/

 

2. The above call will return 202 if the request is accepted. It will also return an  operation ID in the header: x-ms-request-id: 92fc04ca3f8e91538560ae8e964ec0

 

3. Using the operation ID returned from the above POST call, you make a GET operationstatus call. This call will let you know the result of execution of ‘change the deployment configuration’. Did the operation succeeded or failed?
The get-operationstatus call is documented at: https://msdn.microsoft.com/en-us/library/azure/ee460783.aspx
Example: https://management.core.windows.net/<subscription-id>/operations/<request-id>