【问题标题】:New-AzureRmResourceGroup : 'this.Client.SubscriptionId' cannot be nullNew-AzureRmResourceGroup:“this.Client.SubscriptionId”不能为空
【发布时间】:2017-06-01 06:52:27
【问题描述】:

我正在尝试通过 powershell 在 Azure 中创建新的 Web 应用服务,但遇到以下错误:

New-AzureRmResourceGroup : 'this.Client.SubscriptionId' cannot be null.

$webAppName = "powershelldemowebapp"
$ResourceGroupName = "PowerShellResourceGroup"          
$Location = "East Asia"

Login-AzureRmAccount -ServicePrincipal -Tenant 000000-0000-0000-0000-00000 -Credential $psCred
Get-AzureSubscription
Select-AzureSubscription  -SubscriptionId 00000-0000-0000-000-0000
New-AzureRmWebApp -Name $webAppName  -ResourceGroupName $ResourceGroupName  -Location $Location 

【问题讨论】:

  • 如果您有多个 ARM 订阅,使用 Select-AzureSubscription 您无法更改默认订阅。该 cmdlet 仅更改经典订阅。

标签: powershell azure azure-web-app-service azure-powershell alm


【解决方案1】:

Get-AzureSubscriptionSelect-AzureSubscription 是 ASM cmdlet。我注意到你想创建一个 ARM webapp。如果您有多个 ARM 订阅,则使用 Select-AzureSubscription 您无法更改默认订阅。该 cmdlet 仅更改经典订阅。

您需要使用 ARM cmdlet。

Get-AzureRmSubscription Select-AzureRmSubscription -SubscriptionId 00000-0000-0000-000-0000

【讨论】:

  • 这就解释了为什么我的潜艇不会显示...我会好好庆祝一下 - 谢谢。
  • 我只是确保它有效 - 在接受它作为答案之前 - 全部完成 - 谢谢。
  • @Walter 我也有与 Stuart.Sklinar 相同的问题。是否取决于订阅级别。我的订阅详细信息是:**Environment:AzureCloud Account:abc@tenant.onmicrosoft.com TenantId:xxxx SubscriptionId:SubscriptionName:CurrentStorageAccount:** 在这里我找不到任何 SubscriptionId。就是这样我的问题是什么?
  • @A A 您确定您的订阅是基于 ARM 模式还是 ASM 模式?
  • 在我的订阅中,列出了 - 访问 Azure Active Directory。只要。所以我需要订阅更多内容?
【解决方案2】:

这只是建立@Shui.Sklinar 的答案。以下是Azure CLI in powershell 中的类似命令(如果有人正在使用)。

  1. Get-AzSubscription # 获取您帐户下的所有可用订阅。
  2. Select-AzSubscription -SubscriptionId 00000-0000-0000-000-0000 # 选择一个特定的订阅。

【讨论】:

    猜你喜欢
    • 2020-10-06
    • 1970-01-01
    • 1970-01-01
    • 2013-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多