You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Learn about the MSAL-based Azure CLI.
4
-
author: jiasli
5
-
ms.author: jiasli
6
-
ms.date: 09/19/2024
3
+
description: Learn about MSAL-based Azure CLI, the deprecation of accessTokens.json, and how to securely authenticate using MSAL and AzureCliCredential.
7
4
ms.service: azure-cli
8
5
ms.custom: devx-track-azurecli
9
6
keywords: msal, msal-based azure cli
10
7
---
11
8
12
9
# MSAL-based Azure CLI
13
10
14
-
Starting in version 2.30.0, Azure CLI uses Microsoft Authentication Library [(MSAL)](https://github.com/AzureAD/microsoft-authentication-library-for-python) as the underlying authentication library. MSAL uses Azure Active Directory v2.0 authentication flow to provide more functionality and increases security for token cache.
11
+
Starting with version 2.30.0, Azure CLI uses Microsoft Authentication Library [(MSAL)][09] as its
12
+
underlying authentication library. MSAL uses the Azure Active Directory v2.0 authentication flow to
13
+
provide enhanced functionality and increase security for token cache.
15
14
16
15
> [!WARNING]
17
-
> BREAKING CHANGES are introduced in Azure CLI 2.30.0. Carefully read document prior to installation.
16
+
> Breaking Changes are introduced in Azure CLI 2.30.0. Carefully read this document before
17
+
> installation.
18
18
19
19
## `accessTokens.json` deprecation
20
20
21
-
Previous versions of Azure CLI saved Azure AD Authentication Library (ADAL) tokens and service principal entries to `~/.azure/accessToken.json`. The latest versions of the Azure CLI use MSAL and no longer generate `accessTokens.json`. Any existing workflow depending on `accessTokens.json` no longer works.
21
+
Previous versions of Azure CLI saved Azure AD Authentication Library (ADAL) tokens and service
22
+
principal entries to `~/.azure/accessToken.json`. The latest versions of the Azure CLI use MSAL and
23
+
no longer generate `accessTokens.json`. Existing workflows depending on `accessTokens.json` no longer
24
+
work.
22
25
23
-
The MSAL token cache and service principal entries are saved as encrypted files on Windows, and plaintext files on Linux and macOS.
26
+
The MSAL token cache and service principal entries are saved as encrypted files on Windows, and
27
+
plaintext files on Linux and macOS.
24
28
25
29
> [!IMPORTANT]
26
-
> When using Azure CLI in a pipeline like Azure DevOps, ensure all tasks and stages are using versions of Azure CLI above v2.30.0 for MSAL-based Azure CLI. Azure CLI 2.30.0 is not backwards compatible with prior versions and throws an error when working with versions prior to 2.30.0.
30
+
> When using Azure CLI in a pipeline, such as Azure DevOps, ensure all tasks and stages are using
31
+
> versions of Azure CLI v2.30.0 or higher for MSAL-based Azure CLI. Azure CLI 2.30.0 isn't backward
32
+
> compatible with prior versions and throws an error when working with versions earlier than 2.30.0.
27
33
28
34
## Alternatives to consider
29
35
30
-
Alternatives you may consider for stability:
36
+
Alternatives to consider for stability:
31
37
32
38
### Calling `az account get-access-token`
33
39
34
-
You can manually call [`az account get-access-token`](/cli/azure/account#az_account_get_access_token) in a terminal or use a subprocess to call it from another programming language. By default, the returned access token is for Azure Resource Manager (ARM) and the default subscription/tenant shown in [`az account show`](/cli/azure/account#az_account_show).
40
+
You can manually call [`az account get-access-token`][04] in a terminal or use a subprocess to call
41
+
it from another programming language. By default, the returned access token is for Azure Resource
42
+
Manager (ARM) and the default subscription/tenant shown in [`az account show`][05].
35
43
36
44
```azurecli
37
45
# get the active subscription
@@ -44,20 +52,33 @@ az account get-access-token
44
52
az account get-access-token --subscription "<subscription ID or name>"
45
53
```
46
54
47
-
To learn more about the access tokens, see [Sign in with Azure CLI](./authenticate-azure-cli-interactively.md#refresh-tokens).
55
+
To learn more about access tokens, see [Sign in with Azure CLI][01].
48
56
49
-
### Using `AzureCliCredential`
57
+
### Using AzureCliCredential
50
58
51
-
`AzureCliCredential` is a credential type in all existing language SDKs. It uses subprocess to call `az account get-access-token` to get an access token for the current logged-in account.
59
+
`AzureCliCredential` is a credential type in all existing language SDKs. It uses a subprocess to
60
+
call `az account get-access-token` to retrieve an access token for the current logged-in account.
52
61
53
62
## See also
54
63
55
64
- MSAL
56
-
-[Overview of the Microsoft Authentication Library (MSAL)](/azure/active-directory/develop/msal-overview)
57
-
-[Migrate applications to the Microsoft Authentication Library (MSAL)](/azure/active-directory/develop/msal-migration)
65
+
-[Overview of the Microsoft Authentication Library (MSAL)][03]
66
+
-[Migrate applications to the Microsoft Authentication Library (MSAL)][02]
58
67
- Python
59
-
-[AzureCliCredential Class](/python/api/azure-identity/azure.identity.azureclicredential) in Python
68
+
-[AzureCliCredential Class][08] in Python
60
69
- .NET
61
-
-[AzureCliCredential Class](/dotnet/api/azure.identity.azureclicredential) in .NET
70
+
-[AzureCliCredential Class][06] in .NET
62
71
- Java
63
-
-[AzureCliCredential Class](/java/api/com.azure.identity.azureclicredential) in Java
0 commit comments