简体   繁体   中英

How do you automate azure login with runbooks?

I want to run a script in powershell azure and when it runs I need it to connect automatically to Azure without prompting for specific user login and password details. I have automation accounts set up , can somebody advise the best way to do this?

You need to create azure automation connection or use variable to pass in username\\password combination. after that just use regular login with silent auth. Example of using azure automation connection

$servicePrincipalConnection = Get-AutomationConnection -Name "name goes here"
Add-AzureRmAccount -ServicePrincipal -TenantId $servicePrincipalConnection.TenantId `
    -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint `
    -ApplicationId $servicePrincipalConnection.ApplicationId | Out-Null

Reading: https://docs.microsoft.com/en-us/azure/automation/automation-connections

Azure powershell silent auth can be done the same way, or just using Azure AD User:

$cred = [pscredential]::new('user',(ConvertTo-SecureString -String 'password' -AsPlainText -Force))
Connect-AzureAD -Credential $cred

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