Azure New-AzStorageAccount: Subscription was not found error

How to use resolve the Subscription was not found error when using New-AzStorageAccount

Symptoms

When using New-AzStorageAccount a Subscription was not found error appears, even though the subscription definitely exists, is accessible, and has even been used by other entries in the same script.

1Subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx was not found.

Cause

The Microsoft.Storage Resource Provider is not registered for this subscription. With some other cmdlets the lack of Provider throws a more descriptive error, for example Set-AzDiagnosticsSetting will return the following when microsoft.insights is not registered.

1Exception type: ErrorResponseException, 
2Message: The subscription 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' 
3is not registered to use microsoft.insights., 
4Code: SubscriptionNotRegistered, Status

Solution

Register the Microsoft.Storage Resource Provider for the selected subscription. This can be done using the Resource providers blade on the Subscription page in the Azure Portal.

Use the Azure Portal to register a Resource Provider