无法使用 Powershell 连接到正确的 Azure 订阅

Goe*_*ems 3 powershell azure azure-powershell

我在 Azure 上有很多租户,我使用 Powershell 来管理它们。

我正在连接我的帐户:

Login-AzureRmConnect

Account                     SubscriptionName          TenantId                             Environment
-------                     ----------------          --------                             -----------
XXX@XXXX.XXX                Microsoft Partner Network XXXXX-XXXX-XXXX-XXXX-XXXX            AzureCloud
Run Code Online (Sandbox Code Playgroud)

当我想用有效的 SubscriptionID 更改订阅时,我有以下答案:

Select-AzureRmSubscription -SubscriptionId "XXXX-XXXX-XXXX-XXXXX-XXXXXX"
Select-AzureRmSubscription : Please provide a valid tenant or a valid subscription.
Au caractère Ligne:1 : 1
+ Select-AzureRmSubscription -SubscriptionId "XXXX-XXXX-XXXX-XXXXX-X ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError : (:) [Set-AzureRmContext], ArgumentException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.SetAzureRMContextCommand
Run Code Online (Sandbox Code Playgroud)

当我这样做时Get-AzureRmSubscription

Get-AzureRmSubscription
AVERTISSEMENT : Unable to acquire token for tenant 'XXXXX-XXXX-XXXX-XXXX-XXXX'
AVERTISSEMENT : Unable to acquire token for tenant 'XXXXX-XXXX-XXXX-XXXX-XXXX'
AVERTISSEMENT : Unable to acquire token for tenant 'XXXXX-XXXX-XXXX-XXXX-XXXX'
AVERTISSEMENT : Unable to acquire token for tenant 'XXXXX-XXXX-XXXX-XXXX-XXXX'
AVERTISSEMENT : Unable to acquire token for tenant 'XXXXX-XXXX-XXXX-XXXX-XXXX'

Name                          Id                                   TenantId                             State
----                          --                                   --------                             -----
Microsoft Partner Network     XXXXX-XXXX-XXXX-XXXX-XXXX            XXXXX-XXXX-XXXX-XXXX-XXXX            Enabled
Microsoft Azure               XXXXX-XXXX-XXXX-XXXX-XXXX            XXXXX-XXXX-XXXX-XXXX-XXXX            Enabled
XXXX - XXXXXXX                XXXXX-XXXX-XXXX-XXXX-XXXX            XXXXX-XXXX-XXXX-XXXX-XXXX            Enabled
Run Code Online (Sandbox Code Playgroud)

在它工作之前,在 Azure 的门户中没有变化。

你能帮助我吗 ?

感谢您

小智 8

我无法使用评论。

是否其他订阅基于不同的租户?如果是这种情况,请尝试使用Connect-AzureRmAccount -TenantId