Set-AzContext在Azure Cloud Shell中有效,但在Azure PowerShell中无效 [英] Set-AzContext works in Azure Cloud Shell but doesn't in Azure PowerShell
问题描述
当我执行以下命令时
Clear-AzureProfile
Connect-AzAccount -TenantID xxxxxxxxxxxxxxxxxxx
Set-AzContext -SubscriptionId xxxxxxxxxxxxxxxxxxx
我在Azure PowerShell
中的
出现此错误.
in Azure PowerShell
i get this error.
Set-AzContext : Please provide a valid tenant or a valid subscription.
At line:6 char:1
+ Set-AzContext -SubscriptionId xxxxxxxxxxxxxxxxxxx
如果我在Azure Cloud Shell
中运行相同的命令,则可以运行
and if i run the same command in Azure Cloud Shell
it works
Name Account SubscriptionName Environment TenantId
xxxx xxxxxxx xxxx xxxx xxxx
我从免费试用版切换为即用即付订阅,并且在两种环境下都使用凭据进行即用即付,但这是行不通的.谁能帮忙
I switched from free-trial to pay-as-you-go subscription and using credentials for pay-as-you-go in both environment but it doesn't work. can anyone help
推荐答案
关闭您的Powershell并打开一个新的Powershell,或者使用Clear-AzContext
而不是Clear-AzureProfile
.然后使用Connect-AzAccount -Tenant xxxxx -Subscription xxxxx
,它应该可以工作.
Close your powershell and open a new one, or use Clear-AzContext
, not Clear-AzureProfile
. Then use Connect-AzAccount -Tenant xxxxx -Subscription xxxxx
, it should work.
这篇关于Set-AzContext在Azure Cloud Shell中有效,但在Azure PowerShell中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!