Azure 自动化中的多个运行方式帐户
Multiple RunAs Accounts in Azure Automation
是否可以在 Azure 自动化中拥有多个 runas 帐户?
我在网上进行了研究,包括 Microsoft 文章,但找不到答案。
不,您可以只拥有两个 运行 作为帐户。(在 CSP 订阅中,您可以只拥有新的 运行 作为帐户。)一个用于管理新的 ARM 资源,另一个classic 一个管理经典资源。
不必是另一个 AzureRunAs 帐户。 Runbook 结合使用连接和证书进行身份验证。
因此,您可以添加一个新连接并让它使用不同的服务主体。
首先添加证书,然后创建连接并配置服务主体。我从未对 different/multiple 连接使用相同的 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
}
}
是否可以在 Azure 自动化中拥有多个 runas 帐户?
我在网上进行了研究,包括 Microsoft 文章,但找不到答案。
不,您可以只拥有两个 运行 作为帐户。(在 CSP 订阅中,您可以只拥有新的 运行 作为帐户。)一个用于管理新的 ARM 资源,另一个classic 一个管理经典资源。
不必是另一个 AzureRunAs 帐户。 Runbook 结合使用连接和证书进行身份验证。 因此,您可以添加一个新连接并让它使用不同的服务主体。 首先添加证书,然后创建连接并配置服务主体。我从未对 different/multiple 连接使用相同的 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
}
}