Subscription not found when using Get-AzStorageAccountNameAvailability

Published On: January 26, 2024Last Updated: January 26, 2024By Tags: , 1.7 min readViews: 117

TOC

Let’s assume you are creating resources for an internal project, customer project etc. and you have written a script to ensure the process is not prone to user error, and is repeatable.

When it comes to running the script, throughout all of the testing there has not been a single hiccup, the script is A-OK. You then come to run the script on brand-new subscription, or in a customers environment. You are hit with an error, and no matter how much googling you do, you struggle to find that golden nugget.

Well, that is how this post originated. Hopefully, this article will pop-up high enough to stop the endless scrolling 😉.

The Problem

The script that I was running, checks for the availability of a storage account name, before going and creating a storage account (snippet of the check below).

Copy to Clipboard

As soon as it hits the Get-AzStorageAccountNameAvailability command, it throws an exception almost instantly saying ‘Subscription <Your Subscription ID> was not found’. 

subscriotionnot found
subscriotionnot found

Instantly, you start checking everything, checking the subscription id character by character, checking your account permissions, and even running it again within your environment (talking from experience).

The Solution

The solution will astound you…

This simply comes down to the Microsoft.Storage resource provider not being registered within Azure. So let’s get that enabled by following the below steps.

  • Navigate to your Subscription Blade
  • Select the relevant subscription
  • In the left-hand pane, select Resource Providers
resourceProviders
resourceProviders
  • Using the search bar, type Microsoft.Storage
Microsoft.StorageSearch
Microsoft.StorageSearch
  • Click on the whitespace next to the name (If you click the name, it will display additional information)
  • From the Ribbon click Register
  • Await for the success notification and for the resource to appear as Registered
  • Re-run your code snippet

Now the resource is registered, the Get-AzStorageAccountNameAvailability command is able to check the availability, and then it goes on to complete the create operation.

PostRegistrationCreation
PostRegistrationCreation

Conclusion

It is frustrating that the PowerShell module does not direct you to possible causes, but I hope you find this useful.

Subscription not found when using Get-AzStorageAccountNameAvailability

Published On: January 26, 2024Last Updated: January 26, 2024By Tags: , 1.7 min readViews: 117

TOC

Let’s assume you are creating resources for an internal project, customer project etc. and you have written a script to ensure the process is not prone to user error, and is repeatable.

When it comes to running the script, throughout all of the testing there has not been a single hiccup, the script is A-OK. You then come to run the script on brand-new subscription, or in a customers environment. You are hit with an error, and no matter how much googling you do, you struggle to find that golden nugget.

Well, that is how this post originated. Hopefully, this article will pop-up high enough to stop the endless scrolling 😉.

The Problem

The script that I was running, checks for the availability of a storage account name, before going and creating a storage account (snippet of the check below).

Copy to Clipboard

As soon as it hits the Get-AzStorageAccountNameAvailability command, it throws an exception almost instantly saying ‘Subscription <Your Subscription ID> was not found’. 

subscriotionnot found
subscriotionnot found

Instantly, you start checking everything, checking the subscription id character by character, checking your account permissions, and even running it again within your environment (talking from experience).

The Solution

The solution will astound you…

This simply comes down to the Microsoft.Storage resource provider not being registered within Azure. So let’s get that enabled by following the below steps.

  • Navigate to your Subscription Blade
  • Select the relevant subscription
  • In the left-hand pane, select Resource Providers
resourceProviders
resourceProviders
  • Using the search bar, type Microsoft.Storage
Microsoft.StorageSearch
Microsoft.StorageSearch
  • Click on the whitespace next to the name (If you click the name, it will display additional information)
  • From the Ribbon click Register
  • Await for the success notification and for the resource to appear as Registered
  • Re-run your code snippet

Now the resource is registered, the Get-AzStorageAccountNameAvailability command is able to check the availability, and then it goes on to complete the create operation.

PostRegistrationCreation
PostRegistrationCreation

Conclusion

It is frustrating that the PowerShell module does not direct you to possible causes, but I hope you find this useful.