-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add doc for MSAL-based Azure CLI (#2807)
- Loading branch information
Showing
7 changed files
with
82 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
title: MSAL-based Azure CLI | Microsoft Docs | ||
description: Learn about the MSAL-based Azure CLI. | ||
author: jiasli | ||
ms.author: jiasli | ||
manager: yonzhan | ||
ms.date: 10/28/2021 | ||
ms.topic: conceptual | ||
ms.service: azure-cli | ||
ms.devlang: azurecli | ||
ms.custom: devx-track-azurecli, seo-azure-cli | ||
keywords: msal, msal-based azure cli | ||
--- | ||
|
||
# MSAL-based Azure CLI | ||
|
||
Starting in version 2.30.0, Azure CLI uses [MSAL](https://github.com/AzureAD/microsoft-authentication-library-for-python) as the underlying authentication library. MSAL uses AAD v2.0 authentication flow to provide more functionality and increases security for token cache. | ||
|
||
> [!WARNING] | ||
> BREAKING CHANGES are introduced in Azure CLI 2.30.0. Carefully read document prior to installation. | ||
## `accessTokens.json` deprecation | ||
|
||
Previous versions of Azure CLI save ADAL tokens and service principal entries to `~/.azure/accessToken.json`. Latest versions of Azure CLI use MSAL and no longer generate `accessTokens.json`. Any existing workflow depending on `accessTokens.json` no longer works. | ||
|
||
The MSAL token cache and service principal entries are saved as encrypted files on Windows, and plaintext files on Linux and MacOS. | ||
|
||
## Alternatives to consider | ||
|
||
Below are several alternatives you may consider: | ||
|
||
### Calling `az account get-access-token` | ||
|
||
You can manually call [`az account get-access-token`](/cli/azure/account#az_account_get_access_token) in a terminal or use 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). | ||
|
||
```azurecli | ||
# get the active subscription | ||
az account show --output table | ||
# get access token for the active subscription | ||
az account get-access-token | ||
# get access token for a specific subscription | ||
az account get-access-token --subscription "<subscription ID or name>" | ||
``` | ||
|
||
### Using `AzureCliCredential` | ||
|
||
`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. | ||
|
||
## See also | ||
|
||
* MSAL | ||
* [Overview of the Microsoft Authentication Library (MSAL)](/azure/active-directory/develop/msal-overview) | ||
* [Migrate applications to the Microsoft Authentication Library (MSAL)](/azure/active-directory/develop/msal-migration) | ||
* Python | ||
* [AzureCliCredential Class](/python/api/azure-identity/azure.identity.azureclicredential) in Python | ||
* .NET | ||
* [AzureCliCredential Class](/dotnet/api/azure.identity.azureclicredential) in .NET | ||
* Java | ||
* [AzureCliCredential Class](/java/api/com.azure.identity.azureclicredential) in Java |
Oops, something went wrong.