No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName> to set the default subscription

我与影子孤独终老i 提交于 2019-11-30 18:29:30

Use this one to select your default subscription:

Select-AzureSubscription -Default -SubscriptionName "My Production (Pay-As-You-Go)"

You can also choose to use -SubscriptionId (and the GUID) instead of the name.

For more information on the Select-AzureSubscription commandlet; type Get-Help Select-AzureSubscription .

If this doesn't work, try running first, before selecting your subscription:

 Add-AzureAccount 

Update if you're still facing trouble:

If you are using AzureRM / with old cmdlets (or just AzureRM) and are still facing problems I would strongly recommend you to check if you have multiple versions of AzureRM.Profile module . I've encountered this numerous times when one version is installed under Program Files and another under my user profile (or somewhere else in PSModulePath).

To list what modules / versions are installed :

Get-Module AzureRm.Profile -ListAvailable

If you have multiple instances and versions of this it might create some trouble with some of your cmdlets.

When I tried to Select-AzureSubscription it was giving me the error "Subscription does not exist" when I was passing 100% correct subscription name or subscription Id that I found on Azure portal and from powershell:

$account = Login-AzureRmAccount
$account.Context.Subscription.SubscriptionId
$account.Context.Subscription.SubscriptionName

Adding Azure account fixed the problem for me:

Add-AzureAccount
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!