Home > database >  Creating Azure Storage account from PowerShell giving error
Creating Azure Storage account from PowerShell giving error

Time:03-01

I have Azure subscription where I am the owner of it. So, I have access to manage all resources.

I successfully login to Azure Account from PowerShell using command Connect-AzAccount

Now, I am trying to create a storage account using script like below:

New-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $my_storage_Acc -Location $location -SkuName Standard_LRS

But after executing the above command, I am getting the error like this:

The client with my_object_id does not have authorization to perform action over scope(code:Authorization Failed)

Can anyone help me why I'm getting this error though I've owner role for subscription and how to get rid of that error?

CodePudding user response:

As per the error, it said that you don't have enough permission to do this action. It's an authorization issue. But you said that you are the owner of this subscription. I have a question, what have you declared in the my_object_id?

To create Azure Storage Account you can use this script.

# Variables
$ResourceGroup="MyResourceGroup007"
$StorageName="webappstorage007"
$Location="West US"

# Create a Resource Group
New-AzResourceGroup -Name $ResourceGroup -Location $Location

# Create Storage Account
New-AzStorageAccount -Name $StorageName -ResourceGroupName $ResourceGroup -Location $Location -SkuName Standard_LRS

This script can create a storage account successfully. Check the following Screenshot.

enter image description here

  • Related