AzureCliCredential Class
Authenticates by requesting a token from the Azure CLI.
This requires previously logging in to Azure via "az login", and will use the CLI's currently logged in identity.
- Inheritance
-
builtins.objectAzureCliCredential
Constructor
AzureCliCredential(*, tenant_id: str = '', additionally_allowed_tenants: List[str] | None = None, process_timeout: int = 10)
Keyword-Only Parameters
Name | Description |
---|---|
tenant_id
|
Optional tenant to include in the token request. |
additionally_allowed_tenants
|
Specifies tenants in addition to the specified "tenant_id" for which the credential may acquire tokens. Add the wildcard value "*" to allow the credential to acquire tokens for any tenant the application can access. |
process_timeout
|
Seconds to wait for the Azure CLI process to respond. Defaults to 10 seconds. Default value: 10
|
Examples
Create an AzureCliCredential.
from azure.identity import AzureCliCredential
credential = AzureCliCredential()
Methods
close |
Calling this method is unnecessary. |
get_token |
Request an access token for scopes. This method is called automatically by Azure SDK clients. Applications calling this method directly must also handle token caching because this credential doesn't cache the tokens it acquires. |
close
Calling this method is unnecessary.
close() -> None
get_token
Request an access token for scopes.
This method is called automatically by Azure SDK clients. Applications calling this method directly must also handle token caching because this credential doesn't cache the tokens it acquires.
get_token(*scopes: str, claims: str | None = None, tenant_id: str | None = None, **kwargs: Any) -> AccessToken
Parameters
Name | Description |
---|---|
scopes
Required
|
desired scope for the access token. This credential allows only one scope per request. For more information about scopes, see https://learn.microsoft.com/entra/identity-platform/scopes-oidc. |
Keyword-Only Parameters
Name | Description |
---|---|
claims
|
not used by this credential; any value provided will be ignored. |
tenant_id
|
optional tenant to include in the token request. |
Returns
Type | Description |
---|---|
An access token with the desired scopes. |
Exceptions
Type | Description |
---|---|
the credential was unable to invoke the Azure CLI. |
|
the credential invoked the Azure CLI but didn't receive an access token. |
Azure SDK for Python