Azure 自动化:Runbook:它知道它是 TenantID 吗?

Azure Automation: Runbook: does it know it's TenantID?

下午好

猜测这是真实的关系:

Azure Tenant
» Azure Subscription
  » Azure Automation
    » Runbook

所以我有这个问题:

是否有 PowerShell 命令可用于获取 Runbook 所在的 TenantID 运行?

是的,你可以使用这个位:

(Get-AzContext).Tenant.Id

找出租户的GUID

如果你想运行运行书中的命令,你可以使用这个:

$servicePrincipalConnection = Get-AutomationConnection -Name "AzureRunAsConnection"        
Write-Output $servicePrincipalConnection.TenantId

注意:有个前提,创建自动化账号时需要selectCreate Azure Run As accountYes,否则AzureRunAsConnection 不存在。