2016-06-19 137 views
6

當我嘗試執行Start-AzureService時,我一直在收到上述錯誤。沒有指定默認訂閱。使用Select-AzureSubscription -Default <subscriptionName>設置默認訂閱

以下信息,執行時提示獲取-AzureAccount:執行時

Id     Type Subscriptions      Tenants        
--     ---- -------------      -------        
[email protected] User 12345678-1234-5678-9012-3456789{12345678-1234-5678-9012-3456789} 

和隨後的信息提示獲取-AzureSubscription:

SubscriptionId   : 12345678-1234-5678-9012-3456789
SubscriptionName   : My Production (Pay-As-You-Go) 
Environment    : MyCloud 
DefaultAccount   : [email protected] 
IsDefault     : True 
IsCurrent     : True 
TenantId     : 12345678-1234-5678-9012-3456789
CurrentStorageAccountName : 


Select-AzureSubscription : Parameter set cannot be resolved using the specified named parameters. 

提示,當我嘗試按照建議的命令:

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

回答

11

使用此選擇您的默認值訂閱:

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

您也可以選擇使用-SubscriptionId(和GUID),而不是名字。

有關Select-AzureSubscription commandlet的更多信息;鍵入Get-Help Select-AzureSubscription

如果這不起作用,嘗試先運行,選擇訂閱之前:

如果你仍然面臨麻煩
Add-AzureAccount 

更新:

如果您正在使用AzureRM /舊的cmdlet(或者只是AzureRM)並且仍然面臨問題我強烈建議您檢查是否有多個版本的AzureRM.Profile模塊。當一個版本安裝在Program Files下,另一個版本在我的用戶配置文件(或PSModulePath中的其他位置)下時,我遇到過很多次。

要列出模塊/版本安裝什麼:

Get-Module AzureRm.Profile -ListAvailable 

如果你有多個實例並在此版本中,它可能會造成一些麻煩一些您的cmdlet。

+1

要獲得幫助,它實際上是「Get-Help」。 –

+0

Hi CmdrTchort, 沒有幫助。 使用Select-AzureSubscription -Default -SubscriptionName「我的產品(現收現付)」以「警告:當前和默認參數已被棄用。Select-AzureSubscription將始終更新默認訂閱」和Start-AzureService :沒有指定默認訂閱。 當afterword嘗試使用Select-AzureSubscription -Default 設置默認預訂時。在嘗試使用Start-AzureService -PassThru -Profile STAGING -ServiceName myService時會再次提示。 – BigAlbert

+2

Add-AzureAccount解決了問題 – montelof

2

當我試圖Select-AzureSubscription這是給我的錯誤「認購不存在」當我經過100%正確的訂閱名稱或訂閱ID,我在Azure門戶和PowerShell的發現:

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

添加Azure帳戶爲我解決了問題:

Add-AzureAccount 
+1

您的評論解決了我的問題。謝謝你,先生!!! – papfan