简体   繁体   English

如何使用Runbook自动执行Azure登录?

[英]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. 我想在Powershell Azure中运行脚本,当它运行时,我需要它自动连接到Azure,而无需提示特定的用户登录名和密码详细信息。 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. 您需要创建一个Azure自动连接或使用变量来传递用户名\\密码组合。 after that just use regular login with silent auth. 之后,只需使用带有静默身份验证的常规登录即可。 Example of using azure automation connection 使用Azure自动连接的示例

$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 阅读: https : //docs.microsoft.com/zh-cn/azure/automation/automation-connections

Azure powershell silent auth can be done the same way, or just using Azure AD User: Azure Powershell静默身份验证可以通过相同的方式完成,也可以仅使用Azure AD用户:

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

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

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