How to get an access token with Az cli
Sometimes you need to get an access token for the currently logged in user in Az cli.
az account get-access-token --resource=https://management.azure.com --output tsv --query accessToken
Possible Values for --resource
-
Azure Resource Manager (ARM):
https://management.azure.com/
-
Azure Key Vault:
https://vault.azure.net/
-
Microsoft Graph:
https://graph.microsoft.com/
-
Azure Storage:
https://storage.azure.com/
-
Azure SQL Database:
https://database.windows.net/
-
Azure Active Directory Graph (legacy):
https://graph.windows.net/
-
Azure Data Lake Storage:
https://datalake.azure.net/
-
Azure Cosmos DB:
https://cosmos.azure.com/
-
Azure Monitor:
https://monitor.azure.com/
-
Azure Service Bus:
https://servicebus.azure.net/
-
Azure Cognitive Services:
https://<your-region>.api.cognitive.microsoft.com/
(replace<your-region>
with the appropriate region) -
Azure Batch:
https://batch.core.windows.net/
-
Azure DevOps:
https://dev.azure.com/