credentials Module

Functions

get_azure_cli_credentials

Return Credentials and default SubscriptionID of current loaded profile of the CLI.

Disclaimer: This method is not working for azure-cli-core>=2.21.0 (released in March 2021). It is now recommended to authenticate using https://pypi.org/project/azure-identity/ and AzureCliCredential. See example code below:


   from azure.identity import AzureCliCredential
   from azure.mgmt.compute import ComputeManagementClient
   client = ComputeManagementClient(AzureCliCredential(), subscription_id)

For compatible azure-cli-core version (< 2.20.0), credentials will be the "az login" command: https://docs.microsoft.com/cli/azure/authenticate-azure-cli

Default subscription ID is either the only one you have, or you can define it: https://docs.microsoft.com/cli/azure/manage-azure-subscriptions-azure-cli

New in version 1.1.6.

Deprecated since version 1.1.28.

get_azure_cli_credentials(resource=None, with_tenant=False)

Parameters

resource
str
default value: None

The alternative resource for credentials if not ARM (GraphRBac, etc.)

with_tenant
bool
default value: False

If True, return a three-tuple with last as tenant ID

Returns

tuple of Credentials and SubscriptionID (and tenant ID if with_tenant)

Return type

See also

https://aka.ms/azsdk/python/identity/migration

get_cli_profile

Return a CLI profile class.

Disclaimer: This method is not working for azure-cli-core>=2.21.0 (released in March 2021).

New in version 1.1.6.

Deprecated since version 1.1.28.

get_cli_profile()

Returns

A CLI Profile

Return type

<xref:azure.cli.core._profile.Profile>

Exceptions

ImportError if azure-cli-core package is not available