Azure 自动化 - 如何在不使用资源管理器帐户的情况下进行身份验证

Azure Automation - how to authenticate without using an account with resource manager

我想在 Azure 自动化中使用 powershell 脚本来安排切换 on/off 资源。

我想在不创建帐户的情况下执行此操作,因为我们的域强制执行密码重置。我知道自动化帐户会创建一个证书 - 在使用资源管理器(又名不是 "classic" 帐户)时是否可以使用此证书进行身份验证。

是的,这是一种有效的方法,事实上,如果您创建一个 Azure 自动化帐户并使用默认值,它会为您创建该帐户,您可以透明地使用它。摘自示例运行手册:

$connectionName = "AzureRunAsConnection"
try
{
    # Get the connection "AzureRunAsConnection "
    $servicePrincipalConnection=Get-AutomationConnection -Name $connectionName         

    $null = Add-AzureRmAccount `
        -ServicePrincipal `
        -TenantId $servicePrincipalConnection.TenantId `
        -ApplicationId $servicePrincipalConnection.ApplicationId `
        -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint 
}
catch {
    if (!$servicePrincipalConnection)
    {
        $ErrorMessage = "Connection $connectionName not found."
        throw $ErrorMessage
    } else{
        Write-Error -Message $_.Exception
        throw $_.Exception
    }
}

进行了多次编辑,因为我的大脑停止工作了