Azure 自动化中是否可以有多个 runas 帐户?
我在网上搜索了 Microsoft 文章,但找不到答案。
不必是另一个 AzureRunAs 帐户。Runbook 使用连接和证书的组合进行身份验证。因此,您可以添加一个新连接并让它使用不同的服务主体。首先添加证书,然后创建连接并配置服务主体。我从未对不同/多个连接使用相同的 AzureRunAs 证书进行测试,但如果可能的话,它值得测试。Runbook 身份验证的代码基本保持不变,除了必须更改连接名称等。
看看门户网站:
Automation accounts -> Select the account -> Certificates
Automation accounts -> Select the account -> Connections
我的代码片段:
$connectionName = "CustomConnectionNameHere";
Try {
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName
"Logging in to Azure..."
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
}
}
不,您可以只拥有两个运行身份帐户。(在 CSP 订阅中,您可以只拥有新的运行身份帐户。)一个管理新的 ARM 资源,另一个管理经典资源。