我可以同时在同一台计算机上使用azure-cli访问多个azure帐户吗? [英] Can I access multiple azure accounts with azure-cli from the same machine at same time?

查看:75
本文介绍了我可以同时在同一台计算机上使用azure-cli访问多个azure帐户吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们实际上有多个Azure帐户(出于某些合理的原因),我希望能够在同一台计算机上同时为不同的帐户运行Azure-CLI命令.

We actually have multiple azure accounts (for some valid reason) and I want to be able to run azure-cli commands for different accounts at the same time from the same machine.

问题在于,一旦我使用 azure登录登录到一个Azure帐户,令牌就会存储在〜/.azure目录中,因此我不确定是否可以完全登录到另一个帐户同时在那台机器上.

The problem with that is, once I login to one azure account with azure login, token will be stored in ~/.azure directory so I am not sure if I can login into another account exactly at the same time on that machine.

有没有办法告诉azure-cli不要在本地配置文件中存储令牌,以便我可以使用azure-cli从同一台计算机同时连接到多个帐户?

Is there any way to tell azure-cli not to store token in local profile so that I can use azure-cli to connect to multiple accounts at the same time from same machine?

推荐答案

如果您使用的是Windows或Mac计算机,则令牌分别存储在Windows令牌管理器或OSx密钥链中.仅在Linux系统上,令牌存储在〜/.azure/azureProfile.json

If you are using a windows or mac machine then the tokens are stored in Windows token manager or OSx key chain respectively. Only on Linux systems the tokens are stored in ~/.azure/azureProfile.json

但是,您仍然应该能够在Win/Mac或Linux计算机上使用多个帐户登录.

However, you should still be able to login with multiple accounts on Win/Mac or Linux machines.

azure帐户集"subscription-name"会将订阅设置为默认订阅,并且您执行的所有命令都将针对该订阅运行.

azure account set "subscription-name" will set the subscription as your default subscription and all the commands that you execute will run against that subscription.

每个命令都有-s或--subscription开关,您可以在其中明确指定订阅ID.即使该订阅属于另一个帐户,但如果您已使用该帐户进行了身份验证,它仍然可以正常工作.

Every command has a -s or --subscription switch where you can explicitly specify the subscription id. Even if the subscription belongs to a different account, it should still work if you have authenticated with that account.

对于Linux系统,我建议创建多个用户帐户,然后从这些帐户运行CLI.我认为当来自不同帐户的两个命令尝试访问〜/.azure/azureProfile.json时,可能会出现争用情况.

For Linux system, I would suggest to create multiple user accounts and then run the CLI from those accounts. I think there could be a race condition when two commands from different accounts try to access ~/.azure/azureProfile.json.

这篇关于我可以同时在同一台计算机上使用azure-cli访问多个azure帐户吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆