DevOps Buzz
Search…
⌃K

API

Azure API tips and tricks.

Curl

Curl syntax to get token.
curl -X POST -d 'grant_type=client_credentials&client_id=[APP_ID]&client_secret=[PASSWORD]&resource=https%3A%2F%2Fmanagement.azure.com%2F' https://login.microsoftonline.com/[TENANT_ID]/oauth2/token
Example.
curl -X POST -d 'grant_type=client_credentials&client_id=4g70a597-88b7-41f9-bfe9-9yf4486c9563&client_secret=BdtWthpHRW/J1.Ia]oE7H3a5[/[email protected]&resource=https%3A%2F%2Fmanagement.azure.com%2F' https://login.microsoftonline.com/82bf54ae-4197-4ff2-b1a1-1fd0ca92a6c3/oauth2/token
Get the access_token from the output.
Then use the following syntax.
curl -X GET -H "Authorization: Bearer [TOKEN]" -H "Content-Type: application/json" https://management.azure.com/subscriptions/[SUBSCRIPTION_ID]/providers/Microsoft.Web/sites?api-version=2016-08-01
Example.
curl -X GET -H "Authorization: Bearer eyJDSAFdsfEWFV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IllNRUxIVDBndmIwbXhvU0RvWWZvbWpxZmpZVSIsImtpZCI6IllNRUxIVDBndmIwbXhvU0RvWWZvbWpxZmpZVSJ9.eyJhdWQiOiJodHRwczovL21hbmFnZW1lbnQuYXp1cmUuY29tLyIsImlzcyI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2NlZjA0YjE5LTc3NzYtNGE5NC1iODliLTM3NWM3N2E4ZjkzNi8iLCJpYXQiOjE1ODYzNTUyMjQsIm5iZiI6MTU4NjM1NTIyNCwiZXhwIjoxNTg2MzU5MTI0LCJhaW8iOiI0MmRnWU5DNnE3cGdTaSszS1ArNUZPYk5WakgxQUE9PSIsImFwcGlkIjoiM2Y3MGEyNjMtNzdiNy00MWY5LWJmZTktOWZiNDQ4NmM1MDYzIiwiYXBwaWRhY3IiOiIxIiwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvY2VmMDRiMTktNzc3Ni00YTk0LWI4OWItMzc1Yzc3YThmOTM2LyIsIm9pZCI6ImFiNjkzNzRmLTRlYzgtNDFkMS1iYjE1LWQwMTdjMTMzZWUzZiIsInN1YiI6ImFiNjkzNzRmLTRlYzgtNDFkMS1iYdASDFdfewfHTHRThtDSFSADFmNlZjA0YjE5LTc3NzYtNGE5NC1iODliLTM3NWM3N2E4ZjkzNiIsInV0aSI6IkpyOEFmX1hUc0VpUUNGTEpxTE5PQUEiLCJ2ZXIiOiIxLjAifQ.KowRMIrbtkiDYYs-UntjCd_ny7TqamwA8dM6zpQ41YRUMttnQnDhORo_GHtdD4645pIDJpA0_Tupx16nt7qsiiYd7dk8TUWwg631uJ86vr-8aKQ4g_fJ85KKqvPwwmUnQ5CoRo7_rarbzCfzRvfR39VfUARJRRpfHwkIrl6JUckKhsvZgsKg9VqO7Hmu1cxRRSYThA92VzfwqXGxJU0LtBf6aXOI3J18oNMNxljdhT9F6WEowTOuSVA2zQSLo2FJ2SZRgGEyOyo0XvtjJGrhsiKxkYcq5ueWkDaKpM_yo_rSGZ1kTec1R6ljSADFasdfdsFDEdfasdFsdf" -H "Content-Type: application/json" https://management.azure.com/subscriptions/82bf54ae-4197-4ff2-b1a1-1fd0ca92a6c3/providers/Microsoft.Web/sites?api-version=2016-08-01

References

List all resources types