简体   繁体   English

无法从 az login 登录到 Azure 帐户 - 管理员启用了 MFA

[英]Cannot login to Azure Account from az login - admin enabled MFA

In azure pipelines of Azure DevOps need to use az login to get into azure account.在 Azure DevOps 的 azure 管道中,DevOps 需要使用 az login 才能进入 azure 帐户。 Getting error that admin has enabled MFA and hence cannot login.收到管理员已启用 MFA 并因此无法登录的错误。

Do not want to use:不想使用:

az login -u "username" -p "password"

Also don't want to implement Service Principal as feel that would be overkill.也不想实施服务主体,因为感觉会有点矫枉过正。

How to login with az login from Azure DevOps when MFA is enabled?启用 MFA 后,如何从 Azure DevOps 使用 az login 登录?

You can make use of:您可以使用:

az login --use-device-code

Note: to avoid any mishaps set the subscription you want to use with:注意:为避免任何意外,请设置您要使用的订阅:

az account set --subscription "subscription here"

So you have:所以你有了:

az login --use-device-code
az account set --subscription "subscription here"

It will then generate a url which you can enter into your browser with the generated device code.然后它将生成一个 url,您可以使用生成的设备代码将其输入浏览器。 The other line will set the subscription you want to work with.另一行将设置您要使用的订阅。

This is an intermittent solution as it is not fully automated in that you have to manually open the url and enter the device code.这是一个间歇性解决方案,因为它不是完全自动化的,因为您必须手动打开 url 并输入设备代码。 At least though your pipelines can still execute.至少尽管您的管道仍然可以执行。

As soon as I have a way to automate the process or have a more effective solution will update the answer.一旦我有办法使流程自动化或有更有效的解决方案,我就会更新答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM