问题
I have logged into my Azure account and selected the appropriate subscription. But it always gives the same error
PS C:\WINDOWS\system32> New-AzureRmResourceGroup -Name "AzureMediaServicesSample" -Location "East US"
New-AzureRmResourceGroup : Run Login-AzureRmAccount to login.
At line:1 char:1
+ New-AzureRmResourceGroup -Name "AzureMediaServicesSample" -Location " ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [New-AzureRmResourceGroup], PSInvalidOperationException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzur
eResourceGroupCmdlet
回答1:
I have selected the subscription too using select-azuresubscription
select-azuresubscription
is used for ASM mode.
For ARM mode, you need use Get-AzureRmSubscription -SubscriptionName "your sub" | Select-AzureRmSubscription
to select your subscription.
More information please refer to this example.
Update:
You could use the following cmdlet to check Azure PowerShell version.
Get-Module -ListAvailable -Name Azure -Refresh
You could install the latest PowerShell from the link.
回答2:
I had the same problem and I solved it by changing the environment setting from Bash to Powershell in the upper left corner of the Cloud Shell Window.
来源:https://stackoverflow.com/questions/42827788/new-azurermresourcegroup-command-not-working-in-powershell