Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use the Azure CLI to issue a Microsoft Entra token and call Azure DevOps REST APIs. Since Entra access tokens only last for one hour, they're ideal for quick one-off operations. You can use Azure CLI to acquire a user token for yourself or on behalf of a service principal.
Prerequisites
Category | Requirements |
---|---|
Entra tenant and subscription | Make sure the subscription is associated with the tenant connected to the Azure DevOps organization you're trying to access. If you don't know your tenant or subscription ID, you can find it in the Azure portal. |
Azure CLI | Download and install the Azure CLI. |
Entra app | (If authenticating for a service principal) Create the Entra application and have the app client ID and client secret ready. |
Acquiring an Entra token for yourself
Sign in to the Azure CLI using the
az login
command and follow the on-screen instructions.Set the correct subscription for the signed-in user with these bash commands. Make sure the Azure subscription ID is associated with the tenant connected to the Azure DevOps organization you're trying to access. If you don't know your subscription ID, you can find it in the Azure portal.
az account set -s <subscription-id>
Generate a Microsoft Entra ID access token with the
az account get-access-token
command using the Azure DevOps resource ID:499b84ac-1321-427f-aa17-267ca6975798
.az account get-access-token \ --resource 499b84ac-1321-427f-aa17-267ca6975798 \ --query "accessToken" \ -o tsv