在 Azure 自动化中使用服务主体向 Azure 资源管理器进行身份验证

Authenticating to Azure Resource Manager with a Service Principal in Azure Automation

现在 documented workaround to use ARM in Azure Automation, and it's also well documented 如何使用服务主体向 ARM 进行身份验证。但即使在执行了这些步骤之后,我仍然无法将这些组合起来工作。 运行 我的 Automation with a Service Principal 运行手册总是出现以下错误:

New-AzureTag : Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your 
Azure credentials.
At Add-SubscriptionTags:48 char:48
+ 
    + CategoryInfo          : CloseError: (:) [New-AzureTag], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Tags.Tag.NewAzureTagCommand

Add-AzureAccountSelect-AzureSubscription 都执行得很好,但是当我调用任何 cmdlet 实际执行某些操作时,我得到了上述错误。

当我使用常规 AAD 组织帐户时,我的 Runbook 可以正常工作,所以我认为这不是 Automation/ARM 问题。

运行我在 PC 上使用服务主体的工作流程也有效,所以我认为我的服务主体设置正确。

有人成功实现过这个场景吗?

这是由于 Azure PowerShell 中的一个错误。它已被识别并且有一个工作项来修复它。如果我能找到它,我会添加 GitHub 问题。

更新: 这是 GitHub 问题 https://github.com/Azure/azure-powershell/issues/655