【问题标题】:Azure Powershell Select-AzureSubscription with subscription id带有订阅 ID 的 Azure Powershell Select-AzureSubscription
【发布时间】:2015-11-17 06:00:17
【问题描述】:

我正在使用 Powershell Azure cmdlet 对我拥有的每个订阅执行一些操作。

但是,我的所有订阅都具有相同的名称。因此,如果我执行以下操作:

$subs | ForEach-Object {
    Select-AzureSubscription -Current -SubscriptionName $_.SubscriptionName
    $services = Get-AzureService
    Write-Output "$($services .Length) services under $($_.SubscriptionId) subscription"
}

它始终适用于同一个订阅,因为订阅仅在订阅 ID 上有所不同。

Select-AzureSubscription 没有-SubscriptionId 参数。

有什么想法可以找到解决方法吗?

【问题讨论】:

  • 您可以使用 Set-AzureSubscription 并根据 SubscriptionId,您可以设置一个有效的名称。然后在其余代码中使用该名称。
  • @ramiramilu 你能把它添加为答案吗?我会把它标记为正确的。

标签: powershell azure azure-powershell


【解决方案1】:

不确定这是否是后来添加的,但截至 2015 年 11 月,您可以使用 -SubscriptionId

Write-Host "Selecting Azure subscription using id"
Select-AzureSubscription -SubscriptionId $subscriptionId

【讨论】:

  • @Rick!我正在执行我从 azure 门户下载的 azure gov 云的 powershel 脚本。我收到此错误 - Select-AzureRmSubscription : 提供的订阅 8888888408e8 不存在
【解决方案2】:

如果您是您帐户的帐户管理员,则可以更改订阅的名称。这样,当您或有权访问订阅的任何其他人下载发布设置时,名称将按照您想要的方式设置。

http://rickrainey.com/windows-azure-how-tos/how-to-change-the-name-of-your-windows-azure-subscription/

【讨论】:

    【解决方案3】:

    编辑 publishsettings 文件,为每个订阅指定不同的名称。然后重新导入。届时,您将能够轻松地按名称唯一地访问每一个。

    【讨论】:

    • 这对我不起作用。 Import-AzurePublishSettingsFile 只需更改名称即可在导入时使用原始名称而不是新名称。
    猜你喜欢
    • 2016-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-08
    • 2014-10-14
    • 2020-11-11
    • 2022-01-19
    • 2022-12-18
    相关资源
    最近更新 更多