【发布时间】:2021-05-06 11:16:46
【问题描述】:
我运行以下命令:-
PS C:\WINDOWS\system32> Connect-AzureRmAccount
WARNING: Because the Az modules have all the capabilities of AzureRM modules and more, we will retire the AzureRM
modules on 29 February 2024. Learn more about the migration to Az: http://aka.ms/azpsmigrate.
Account SubscriptionName TenantId Environment
------- ---------------- -------- -----------
**.***@****.onmicrosoft.com e***-b4fb-0*** AzureCloud
PS C:\WINDOWS\system32> az login --tenant "c*f"
You have logged in. Now let us find all the subscriptions to which you have access...
[
{
"cloudName": "AzureCloud",
"id": "b**4",
"isDefault": true,
"name": "Microsoft Azure",
"state": "Enabled",
"tenantId": "c**f",
"user": {
"name": "***@***.onmicrosoft.com",
"type": "user"
}
}
]
PS C:\WINDOWS\system32> Select-AzureSubscription -Current -SubscriptionId "b**4"
Select-AzureSubscription : The term 'Select-AzureSubscription' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ Select-AzureSubscription -Current -SubscriptionId "b1597bc1-913e-4da7 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Select-AzureSubscription:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
但是我得到了上述错误任何建议? 谢谢
编辑
我运行这个命令:-
az login --tenant "c*f"
我得到了这个结果
You have logged in. Now let us find all the subscriptions to which you have access...
[
{
"cloudName": "AzureCloud",
"id": "b**4",
"isDefault": true,
"name": "Microsoft Azure",
"state": "Enabled",
"tenantId": "c**f",
"user": {
"name": "***@***.onmicrosoft.com",
"type": "user"
}
}
]
但是当我运行这个命令时:-
Select-AzureRmSubscription -Subscription "b**4" -Tenant "c**f"
我得到了这个结果
WARNING: Because the Az modules have all the capabilities of AzureRM modules and more, we will retire the AzureRM
modules on 29 February 2024. Learn more about the migration to Az: http://aka.ms/azpsmigrate.
Select-AzureRmSubscription : Please provide a valid tenant or a valid subscription.
At line:1 char:1
+ Select-AzureRmSubscription -Subscription "b ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureRmContext], ArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.SetAzureRMContextCommand
EDIT-2
我试过这个命令:-
PS C:\WINDOWS\system32> Get-AzureRmSubscription -Subscription "b**4" -Tenant "c**f"
但我得到了这个错误:-
Get-AzureRmSubscription : Parameter cannot be processed because the parameter name 'Subscription' is ambiguous.
Possible matches include: -SubscriptionId -SubscriptionName.
At line:1 char:25
+ Get-AzureRmSubscription -Subscription "b1597bc1-913e-4da7-a020-be3029 ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-AzureRmSubscription], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameter,Microsoft.Azure.Commands.Profile.GetAzureRMSubscriptionCommand
所以我运行这个命令:-
PS C:\WINDOWS\system32> Get-AzureRmSubscription -SubscriptionId "b**4" -Tenant "c**f"
但是得到了这个错误:-
WARNING: Because the Az modules have all the capabilities of AzureRM modules and more, we will retire the AzureRM
modules on 29 February 2024. Learn more about the migration to Az: http://aka.ms/azpsmigrate.
WARNING: Unable to acquire token for tenant 'cfcab407-f59a-4db4-aec9-d5d3676d708f'
Get-AzureRmSubscription : Subscription b1597bc1-913e-4da7-a020-be30291a6494 was not found in tenant
cfcab407-f59a-4db4-aec9-d5d3676d708f. Please verify that the subscription exists in this tenant.
At line:1 char:1
+ Get-AzureRmSubscription -SubscriptionId "b1597bc1-913e-4da7-a020-be30 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureRmSubscription], PSArgumentException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.GetAzureRMSubscriptionCommand
【问题讨论】:
-
Select-AzureSubscription 不是 AzureRM 模块的一部分。
-
不要使用
Select-AzureSubscription,请使用Get-AzureRmSubscription -
您指定的租户中是否存在订阅?
-
让我们重新开始:)。您能否更新您的问题并包括您正在运行的最新代码和您获得的输出?此外,请使用租户 ID 和订阅 ID 的前几个字符,而不是“b**4”。谢谢。
-
啊...我应该早点看到这个。您可以尝试使用
Get-AzureRmSubscription而不是Select-AzureRmSubscription(顺便说一句,我找不到Select-AzureRmSubscription)吗?
标签: azure powershell azure-rm