ArgumentNullException - Get-AzureService

别等时光非礼了梦想. 提交于 2019-12-10 16:49:17

问题


I'm trying to use the Windows Azure PowerShell module to manage a subscription.

I have downloaded my certificate (the .publishsettings file) and imported it with Import-AzurePublishSettingsFile and then I've selected my subscription with Select-AzureSubscription neither of which gave errors.

I've also set my subscription using Set-AzureSubscription -SubscriptionName "Blah"

Still, I get a

Get-AzureService : Value cannot be null.
Parameter name: subscriptionId

when running Get-AzureService

I've read getting started guides and various documentation but I can't work out what I'm doing wrong. Which in my mind, makes this a UX problem that Microsoft should address.

Update

I got a bit further, I used

Set-AzureSubscription -SubscriptionName "Blah" -SubscriptionId 0123

which changed the error from Get-AzureService to:

Get-AzureService : Value cannot be null.
Parameter name: managementCertificate

But now I cannot set my certificate since the argument wants an X509Certificate type.


回答1:


There is a better way to authenticate when using the Azure Powershell cmdlets --- Add-AzureAccount. This will prompt you for your login credentials instead of using the service management certificate.

You may still run into some issues because Azure powershell caches your subscriptions in XML files in %appdata%\Windows Azure Powershell.

I would recommend:

  1. Close the Azure Powershell window
  2. Delete the XML files in %appdata%\Windows Azure Powershell.
  3. Open Azure Powershell and run Add-AzureAccount.

This should ensure that you have the correct subscriptions configured.




回答2:


I hope this might help you-

Add-AzureAccount Get-AzurePublishSettingsFile Import-AzurePublishSettingsFile filenamewithpath

filenamewithpath is the publishsetting file with path saved on your pc



来源:https://stackoverflow.com/questions/22817539/argumentnullexception-get-azureservice

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