简体   繁体   中英

How can i login to Azure using an account with MFA using Powershell?

I am currently logging int Azure using

az login -u -p ""

The issue is that the email is MFA and a verification code is needed to be entered in. This login process is used for CICD. Is there a way I can automate this process without having to enter the verification code

Thank you for your valuable suggestion and for directing in the right direction, @fmarz10.

Service principals with various forms of credentials, such as passwords, secret keys, and certificates, can be used to do this. After adding the role you can automate login using

$azureAplicationId ="Your Azure AD Application Id" $azureTenantId= "Your Tenant Id" $azurePassword = ConvertTo-SecureString "strong password" -AsPlainText -Force $psCred = New-Object >System.Management.Automation.PSCredential($azureAplicationId , $azurePassword) Add-AzureRmAccount -Credential $psCred -TenantId $azureTenantId ->ServicePrincipal

REFERENCES

  1. Azure Service Principals
  2. Sign in with Azure PowerShell
  3. Azure Provisioning - Without manual login

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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