Azure / Azure/azure-cli

Support switch local context for various Azure Environments

Open
#10,265 1 comment 4 reactions 1 assignee Claimed by @jiasli View on GitHub
Account act-identity-squad act-platform-engineering-squad Core feature-request
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.**

I'm managing various Azure Environments in Public Azure and Azure Mooncake, and always frustrated to switch context between Azure Accounts, have to switch the cloud environment and sign in again and again...

**Describe the solution you'd like**

I want to have a similar mechanism like what kubectl supports, have multiple local contexts for various Azure environments and accounts, could use the similar commands set as following:

1. `az get-contexts` or `az context list` to list all local contexts
2. `az current-context` or `az context show` to show current Azure Environment (Public Azure, Azure Mooncake, etc.), current Azure AD Account/Service Principal, current default subscription
3. `az use-context` or `az context set` to switch a local context, automatic setting the Azure Cloud Environment and use the cached Azure AD Account/Service Principal token, default subscription for following commands execution
4. `az delete-context` or `az context delete` to delete a local context
5. `az rename-context` or `az context renmae` to rename a local context
6. `az set-context` or `az context update` to update a local context

**Describe alternatives you've considered**

One possible solution is writing some helper scripts to switch cloud environment and sign in a service principal with certificate automatically, but in many Azure Environments we only have an AAD Account and can't sign in without interaction.

**Additional context**

Reference: https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#config

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.