Enable all Resource Providers in Azure with PowerShell

#Azure #PowerShell

After setting up a new Azure Subscription, you'll get errors in the Portal that say Resource Providers are enabled for Azure Services:

Resource provider 'Microsoft.BotService' not registered for the subscription

You might also get the following error message:

(Code: NoRegisteredProviderFound)

To fix these errors, you will need to enable the Resource Providers in Azure so that you can allow management from the Portal.

You can enable these Resource Providers one-by-one manually through the portal by navigating to the Subscription > Resource Providers and clicking the “Register” button, but this can take a long time if you want to enable all Resource Providers.

To add them quickly, you can run a one-line PowerShell command to enable all that are currently disabled.

To run this command, you'll need Owner permissions on the Subscription.

You'll also need the Azure Powershell module installed by running the command in PowerShell as an Administrator: Install-Module -Name Az

Run this command in PowerShell and authenticate with your credentials in the popup:

Connect-AzAccount

Get-AzResourceProvider -ListAvailable | where-object {$_.RegistrationState -eq 'NotRegistered'} | Register-AzResourceProvider 

After running this command, all of the Providers will have the Status of “Registering” for a few minutes, then switch to “Registered”:

After this is complete, you'll be able to use all Azure services without this error message.

References

Discuss...