Set-AzContext在Azure Cloud Shell中有效,但在Azure PowerShell中无效 [英] Set-AzContext works in Azure Cloud Shell but doesn't in Azure PowerShell

查看:73
本文介绍了Set-AzContext在Azure Cloud Shell中有效,但在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆