Skip to content

Commit 944b9c6

Browse files
authored
Refreshed, reflowed, converted to link refs (#5399)
1 parent 4f786c3 commit 944b9c6

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed
Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,45 @@
11
---
22
title: MSAL-based Azure CLI | Microsoft Docs
3-
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.
74
ms.service: azure-cli
85
ms.custom: devx-track-azurecli
96
keywords: msal, msal-based azure cli
107
---
118

129
# MSAL-based Azure CLI
1310

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.
1514

1615
> [!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.
1818
1919
## `accessTokens.json` deprecation
2020

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.
2225

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.
2428

2529
> [!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.
2733
2834
## Alternatives to consider
2935

30-
Alternatives you may consider for stability:
36+
Alternatives to consider for stability:
3137

3238
### Calling `az account get-access-token`
3339

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].
3543

3644
```azurecli
3745
# get the active subscription
@@ -44,20 +52,33 @@ az account get-access-token
4452
az account get-access-token --subscription "<subscription ID or name>"
4553
```
4654

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].
4856

49-
### Using `AzureCliCredential`
57+
### Using AzureCliCredential
5058

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.
5261

5362
## See also
5463

5564
- 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]
5867
- Python
59-
- [AzureCliCredential Class](/python/api/azure-identity/azure.identity.azureclicredential) in Python
68+
- [AzureCliCredential Class][08] in Python
6069
- .NET
61-
- [AzureCliCredential Class](/dotnet/api/azure.identity.azureclicredential) in .NET
70+
- [AzureCliCredential Class][06] in .NET
6271
- Java
63-
- [AzureCliCredential Class](/java/api/com.azure.identity.azureclicredential) in Java
72+
- [AzureCliCredential Class][07] in Java
73+
74+
<!-- link references -->
75+
76+
[01]: ./authenticate-azure-cli-interactively.md#refresh-tokens
77+
[02]: /azure/active-directory/develop/msal-migration
78+
[03]: /azure/active-directory/develop/msal-overview
79+
[04]: /cli/azure/account#az_account_get_access_token
80+
[05]: /cli/azure/account#az_account_show
81+
[06]: /dotnet/api/azure.identity.azureclicredential
82+
[07]: /java/api/com.azure.identity.azureclicredential
83+
[08]: /python/api/azure-identity/azure.identity.azureclicredential
84+
[09]: https://github.com/AzureAD/microsoft-authentication-library-for-python

0 commit comments

Comments
 (0)