Azure PowerShell error: The subscription is not entitled to use the resource


This is an error I’ve seen quite a few times. Every time I see the error it takes me a while to remember what the issue is, hopefully this post will help me remember one of the causes. I had successfully authenticated to my Azure Subscription using Add-AzureAccount and  ran the following to create a new Site Recovery Vault:

 New-AzureSiteRecoveryVault –Location "North Europe" -Name "RecoveryVault" 

The error returned was:

New-AzureSiteRecoveryVault : Operation failed.

ClientRequestId:

ForbiddenError: The subscription is not entitled to use the resource

At line:1 char:2

+ New-AzureSiteRecoveryVault -Location $Region -Name “RecoveryVault”

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : CloseError: (:) [New-AzureSiteRecoveryVault], SerializationException

+ FullyQualifiedErrorId : Microsoft.Azure.Commands.RecoveryServices.CreateAzureSiteRecoveryVault

 

As the error mentioned the subscription to investigate further I ran:

 Get-AzureSubscription 

This returned:

SubscriptionId : aa8c470a-22fb-4b79-a24f-729b82XXXXXX

SubscriptionName : XXXXXX

Environment : AzureCloud

SupportedModes : AzureServiceManagement,AzureResourceManager

DefaultAccount : XXXXXX@XXXXXX.com

Accounts : {XXXXXX@XXXXXX.com}

IsDefault : True

IsCurrent : True

CurrentStorageAccountName :

TenantId : ee047b7f-ca78-49f1-b7f6-845fa0XXXXXX

 

I could see that from this output that the property CurrentStorageAccountName is empty.

I then ran the following to set the current storage account (with my subscription name and storage account name):

 Set-AzureSubscription -SubscriptionName "XXXXXX" -CurrentStorageAccountName "XXXXXX" 

Then retried the original command:

 New-AzureSiteRecoveryVault –Location "North Europe" -Name "RecoveryVault" 

 

Success! This now returned:    Vault has been created

The reason I could not create the Recovery Vault is that it needs a Storage Account to use. If there is no current storage account selected the Recovery Vault cannot be created. I have seen the same error when creating other resources on Azure that rely on a storage account being selected.

Comments (0)

Skip to main content