gpt4 book ai didi

powershell - Azure PowerShell Start-AzureAutomationRunbook 未指定默认订阅

转载 作者:行者123 更新时间:2023-12-03 03:04:34 29 4
gpt4 key购买 nike

VSTS 上的 Azure PowerShell v2.* 能够执行

Get-AzureRmResourceGroup

成功并返回正确的结果...好!这有望证明 VSTS 和 Azure 帐户之间的身份验证按预期工作。

当我尝试以下命令时:

Start-AzureAutomationRunbook -AutomationAccountName "automationaccountname" -Name "RunbookName"

我得到这个:

No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName> to set the default subscription.

但是,VSTS 之前已经自动执行这些命令:

Add-AzureRMAccount -ServicePrincipal -Tenant ******** -Credential System.Management.Automation.PSCredential -EnvironmentName AzureCloud
Select-AzureRMSubscription -SubscriptionId 12345678-1234-1234-1234-1234567890AB -TenantId ********

我不确定需要执行什么,因为上一个命令已选择订阅。有什么线索吗?

最佳答案

所以事情是这样的。此时有两个适用于 PowerShell 的 Azure 模块。有 Azure 和 AzureRM。 Azure 模块处理“经典”模型资源,而 AzureRM 模块则处理 ARM(Azure 资源管理)资源。它们中的每一个都或多或少地彼此独立运作,偶尔有一些小的重叠。这里的关键是任何以 *-AzureRM* 开头的内容都与 AzureRM 模块相关。这些 cmdlet 使用来自 Add-AzureRMAccount cmdlet 和 Set-AzureRMContext(Select-AzureRMSubscription 是别名)的登录信息。如果您运行的命令不是以“*-AzureRM”开头,那么您很可能需要通过 Add-AzureAccount cmdlet 登录到经典模块能够执行该命令,或者如果您已经执行了该操作,则只需使用 Select-AzureSubscription cmdlet 指定要使用的订阅即可。

最可能的解决方法:仔细检查这是否是经典 Runbook。如果它没有显示“经典”,请尝试使用 AzureRM 命令:

Start-AzureRmAutomationRunbook -AutomationAccountName "automationaccountname" -Name "RunbookName"

如果这不起作用,那么您需要确保您已登录到经典模块,并且可以查看您的订阅:

Get-AzureSubscription -SubscriptionId 12345678-1234-1234-1234-1234567890AB

如果您可以看到订阅,则可以运行相同的操作,只需将其通过管道传输到 Select-AzureSubscription

Get-AzureSubscription -SubscriptionId 12345678-1234-1234-1234-1234567890AB | Select-AzureSubscription

如果您没有看到列出的订阅,您可以使用 Add-AzureAccount cmdlet 使用与该订阅关联的帐户登录 Azure,然后重复 Get/Select-根据需要订阅 cmdlet。

关于powershell - Azure PowerShell Start-AzureAutomationRunbook 未指定默认订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45742860/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com