wiki:connect_azure_rest_api
This is an old revision of the document!
Table of Contents
Connect to Azure REST API
This uses so-called client credentials grant for accessing the API. There are also authorization via code to get the token mentioned below.
In your account open the azure shell. After connecting create the principal
az ad sp create-for-rbac --role Contributor --scope /subscriptions/<your subscription id>
Subscription id can be obtained from URL when you are logged in to portal.azure.com or with this command
az account show --query id -o tsv
You should get the following similar info
{ "appId": "257xxxxxxxxxxxxxxxxxxxxxx", "displayName": "azure-cli-2022-08-30-10-52-10", "password": "xxxxxxxxxxxxxxxxxxxxx", "tenant": "4aedxxxxxxxxxxxxxxxxxxxxxxxxxxxx" }
This data can now be used to get query the API but you still need the BearerToken which can be obtained via this script, which can be used in Postman as a “Pre-request Script”
You can also get the token via curl see this
Tested on
- Microsoft Azure accessed on 2022-08-30
See also
References
wiki/connect_azure_rest_api.1662125424.txt.gz · Last modified: 2022/09/02 13:30 by antisa