[Enhancement Proposal] Share login context between Azure CLI and Azure PowerShell
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Is your feature request related to a problem? Please describe.**
Sharing login context between Azure CLI and Azure PowerShell is not supported by now.
**Describe the solution you'd like**
Azure CLI and Azure PowerShell can share their login context so that users can choose to use either command:
| |Azure CLI | Azure PowerShell |
|-|-----------|------------------|
| login | [`az login`](https://docs.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest#az_login) | [`Connect-AzAccount`](https://docs.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount) |
| change context | [`az account set`](https://docs.microsoft.com/en-us/cli/azure/account?view=azure-cli-latest#az_account_set) | [`Set-AzContext`](https://docs.microsoft.com/en-us/powershell/module/az.accounts/set-azcontext) |
**Additional context**
To share login context, Azure CLI and Azure PowerShell must share 2 things:
| | Azure CLI | Azure PowerShell |
|---------------|---------------------|-----------------------|
| context | `azureProfile.json` | `AzureRmContext.json` |
| token cache | `accessTokens.json` | `TokenCache.dat` |
For token cache, once both migrate to MSAL, `TokenCache.dat` and `accessTokens.json` will be merged into
```
C:\Users\\AppData\Local\.IdentityService\msal.cache
```
so we get shared `msal.cache` out of the box.
But for `AzureRmContext.json` and `azureProfile.json`, it is very hard for Azure CLI to use `AzureRmContext.json` from Azure PowerShell given the internal implementation logic is such different.
Also, Azure CLI faces another issue for tenant/user isolation which should also be addressed first before sharing login context with Azure PowerShell: #15005.
If this is really something we need to achieve, drastic overhaul of Azure CLI and Azure PowerShell is necessary.
Contributor guide
Assessment
This issue has not been assessed yet.