Azure Azure Compute Azure Governance Azure PowerShell

How to register all required Azure Compute resource providers with Azure PowerShell on a new subscription


In this blog post, you’ll learn how to use an Azure PowerShell script to automatically register all the necessary Azure Compute resource providers in a new subscription.

As many of you know, resource providers are essential building blocks in Azure. Without registering the appropriate providers, you might encounter errors or unexpected behavior when deploying or managing resources, especially in a freshly created subscription.




For instance, if you’re working with Azure virtual machines, containers, images, or disks and the required Compute resource providers aren’t registered, your deployments may fail.

Manually registering each provider can be time-consuming and prone to mistakes. That’s why, in this blog post, I’ll show you how to automate the process using an Azure PowerShell script that ensures all necessary Azure Compute resource providers are registered up front. This not only saves time but also helps avoid common deployment pitfalls.


Table of Contents


Prerequisites

  • A new or existing Azure subscription.
  • An Azure Administrator account with the required RBAC roles to run the script.
  • At least version 10.4.1 of the Azure Az PowerShell module is required.



Executing actions and utilizing the Azure PowerShell script

To automate the registration of the required Azure Compute resource providers in a specified new subscription, I’ve created the following Azure PowerShell script. It performs the following actions:

  • Remove the breaking change warning messages.
  • Change the current context to the specified subscription.
  • Register the required Azure resource providers for Containers in the current subscription, if they are not already registered.
  • Register the required Azure resource providers for Core Networking in the current subscription, if they are not already registered.
  • Register the required Azure resource providers for Azure Update Manager in the current subscription, if they are not already registered.
  • Register the required Azure resource providers for Defender for Cloud in the current subscription, if they are not already registered.
  • Register the required Azure resource providers for Azure Automation in the current subscription, if they are not already registered
  • Register the required Azure resource providers for Azure Monitor in the current subscription, if they are not already registered.
  • Register the required Azure resource providers for Azure Policy in the current subscription, if they are not already registered
  • Register the required Azure resource providers for Azure Key Vault in the current subscription, if they are not already registered

To use the script, start by either copying and saving it as “Register-Azure-Compute-resource-providers-in-a-specified-subscription.ps1” or downloading it directly from GitHub. Then, run the script using Windows Terminal, Visual Studio Code, or Windows PowerShell. Alternatively, you can execute it directly from Cloud Shell.


Azure PowerShell script

If you are not using Cloud Shell to run the script, remember to sign in with the Connect-AzAccount cmdlet to link your Azure account. If you have multiple Azure tenants, ensure you select the correct one before running the script by using the Set-AzContext -TenantId cmdlet.


You can then run the script with the required parameters.

.\Register-Azure-Compute-resource-providers-in-a-specified-subscription -SubscriptionName <"your Azure subscription name here"> 

💡 While most resource providers register within a few seconds to a couple of minutes, some may occasionally take up to 10 minutes to complete the registration process.


<#
.SYNOPSIS

A script to register the necessary Azure Compute resource providers in a specified Azure subscription.

.DESCRIPTION

A script to register the necessary Azure Compute resource providers in a specified Azure subscription.
The script will do all of the following:

Remove the breaking change warning messages.
Change the current context to the specified subscription.
Register the required Azure resource providers for Containers in the current subscription, if they are not already registered.
Register the required Azure resource providers for Core Networking in the current subscription, if they are not already registered.
Register the required Azure resource providers for Azure Update Manager in the current subscription, if they are not already registered.
Register the required Azure resource providers for Defender for Cloud in the current subscription, if they are not already registered.
Register the required Azure resource providers for Azure Automation in the current subscription, if they are not already registered
Register the required Azure resource providers for Azure Monitor in the current subscription, if they are not already registered.
Register the required Azure resource providers for Azure Policy in the current subscription, if they are not already registered
Register the required Azure resource providers for Azure Key Vault in the current subscription, if they are not already registered

.NOTES

Filename:       Register-Azure-Compute-resource-providers-in-a-specified-subscriptions.ps1
Created:        27/05/2025
Last modified:  27/05/2025
Author:         Wim Matthyssen
Version:        1.0
PowerShell:     Azure PowerShell and Azure Cloud Shell
Requires:       PowerShell Az (v10.4.1)
Action:         Change variables were needed to fit your needs.
Disclaimer:     This script is provided "As Is" with no warranties.

.EXAMPLE

Connect-AzAccount
Get-AzTenant (if not using the default tenant)
Set-AzContext -tenantID "xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx" (if not using the default tenant)
.\Register-Azure-Compute-resource-providers-in-a-specified-subscription -SubscriptionName <"your Azure subscription name here"> 

-> .\Register-Azure-Compute-resource-providers-in-a-specified-subscription -SubscriptionName sub-prd-myh-compute-01

.LINK

https://wmatthyssen.com/2025/05/29/how-to-register-all-required-azure-compute-resource-providers-with-azure-powershell-on-a-new-subscription/
#>

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Parameters

param(
    # $subscriptionName -> Name of the Azure Subscription
    [parameter(Mandatory =$true)][ValidateNotNullOrEmpty()] [string] $subscriptionName
)

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Variables

$providerNameSpaceContainerInstance = "Microsoft.ContainerInstance"
$providerNameSpaceContainerRegistry = "Microsoft.ContainerRegistry"
$providerNameSpaceContainerService = "Microsoft.ContainerService"
$providerNameSpaceManagedIdentity = "Microsoft.ManagedIdentity"
$providerNameSpaceStorage = "Microsoft.Storage"
$providerNameSpaceNetwork = "Microsoft.Network"
$providerNameSpaceInsights = "Microsoft.Insights"
$providerNameSpaceCompute = "Microsoft.Compute" 
$providerNameSpaceHybridCompute = "Microsoft.HybridCompute"
$providerNameSpaceMaintenance = "Microsoft.Maintenance"
$providerNameSpaceSecurity = "Microsoft.Security"
$providerNameSpacePolicyInsights = "Microsoft.PolicyInsights"
$providerNameSpaceAutomation = "Microsoft.Automation"  
$providerNameSpaceOperationalInsights = "Microsoft.OperationalInsights"
$providerNameSpaceWeb = "Microsoft.Web"
$providerNameSpaceSql = "Microsoft.Sql"
$providerNameSpaceGuestConfiguration = "Microsoft.GuestConfiguration"
$providerNameSpaceManagement = "Microsoft.Management"
$providerNameSpaceKeyvault = "Microsoft.KeyVault"

$global:currenttime = Get-Date -Format "dddd MM/dd/yyyy HH:mm"
$foregroundColor1 = "Green"
$foregroundColor2 = "Yellow"
$writeEmptyLine = "`n"
$writeSeperatorSpaces = " - "

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Remove the breaking change warning messages

Set-Item -Path Env:\SuppressAzurePowerShellBreakingChangeWarnings -Value $true | Out-Null
Update-AzConfig -DisplayBreakingChangeWarning $false | Out-Null
$warningPreference = "SilentlyContinue"

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Write script started

Write-Host ($writeEmptyLine + "# Script started. Without errors, it can take up to 2 minutes to complete" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine 

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Change the current context to the specified subscription

$subName = Get-AzSubscription | Where-Object {$_.Name -like $subscriptionName}

Set-AzContext -SubscriptionId $subName.SubscriptionId | Out-Null 

Write-Host ($writeEmptyLine + "# Specified subscription in current tenant selected" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Register the required Azure resource providers for Containers in the current subscription, if they are not already registered

# Register Microsoft.ContainerInstance resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceContainerInstance | Out-Null

# Register Microsoft.ContainerRegistry resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceContainerRegistry  | Out-Null

# Register Microsoft.ContainerService resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceContainerService | Out-Null

# Register Microsoft.ManagedIdentity resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceManagedIdentity | Out-Null

# Register Microsoft.Storage resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceStorage | Out-Null

Write-Host ($writeEmptyLine + "# All required resource providers for Containers are currently registering or have already registered" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Register the required Azure resource providers for Core Networking in the current subscription, if they are not already registered

# Register Microsoft.Network resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceNetwork | Out-Null

# Register Microsoft.Insights resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceInsights | Out-Null

Write-Host ($writeEmptyLine + "# All required resource providers for Core Networking are currently registering or have already registered" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Register the required Azure resource providers for Azure Update Manager in the current subscription, if they are not already registered

# Register Microsoft.Compute resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceCompute  | Out-Null

# Register Microsoft.HybridCompute resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceHybridCompute | Out-Null

# Register Microsoft.Maintenance resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceMaintenance | Out-Null

Write-Host ($writeEmptyLine + "# All required resource providers for AUM are currently registering or have already registered" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Register the required Azure resource providers for Defender for Cloud in the current subscription, if they are not already registered

# Register Microsoft.Security resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceSecurity | Out-Null

# Register Microsoft.PolicyInsights resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpacePolicyInsights | Out-Null

Write-Host ($writeEmptyLine + "# All required resource providers for Defender for Cloud are currently registering or have already registered" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Register the required Azure resource providers for Azure Automation in the current subscription, if they are not already registered

# Register Microsoft.Automation resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceAutomation | Out-Null

Write-Host ($writeEmptyLine + "# All required resource providers for Azure Automation are currently registering or have already registered" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Register the required Azure resource providers for Azure Monitor in the current subscription, if they are not already registered

# Register Microsoft.OperationalInsights resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceOperationalInsights | Out-Null

# Register Microsoft.Web resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceWeb | Out-Null

# Register Microsoft.Sql resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceSql | Out-Null

Write-Host ($writeEmptyLine + "# All required resource providers for Azure Monitor are currently registering or have already registered" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Register the required Azure resource providers for Azure Policy in the current subscription, if they are not already registered

# Register Microsoft.GuestConfiguration resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceGuestConfiguration | Out-Null

# Register Microsoft.Management resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceManagement | Out-Null

Write-Host ($writeEmptyLine + "# All required resource providers for Azure Policy are currently registering or have already registered" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Register the required Azure resource providers for Azure Key Vault in the current subscription, if they are not already registered

# Register Microsoft.KeyVault resource provider
Register-AzResourceProvider -ProviderNamespace $providerNameSpaceKeyvault | Out-Null

Write-Host ($writeEmptyLine + "# All required resource providers for Azure Key Vault are currently registering or have already registered" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor2 $writeEmptyLine

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Write script completed

Write-Host ($writeEmptyLine + "# Script completed" + $writeSeperatorSpaces + $global:currenttime)`
-foregroundcolor $foregroundColor1 $writeEmptyLine 

## ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------






Quickly list registered resource providers in a subscription

Of course, you can verify all successful resource provider registrations through the Azure Portal, but this process can be time-consuming if there are many providers to check.

That’s why it’s more efficient to use the following Azure PowerShell one-liner to quickly list all registered resource providers in a subscription:

Get-AzResourceProvider | Select-Object ProviderNamespace, RegistrationState



Conclusion

I hope the Azure PowerShell script shared in this blog post helps simplify the registration of all required Azure Compute resource providers in any of your new or existing subscriptions.

If you have any questions or suggestions regarding this blog post or script, feel free to reach out to me on X (@wmatthyssen) or leave a comment. I’ll be happy to assist you.


Unknown's avatar

Wim is an Azure Technical Advisor and Trainer with over fifteen years of Microsoft technology experience. As a Microsoft Certified Trainer (MCT), his strength is assisting companies in the transformation of their businesses to the Cloud by implementing the latest features, services, and solutions. Currently, his main focus is on the Microsoft Hybrid Cloud Platform, and especially on Microsoft Azure and the Azure hybrid services.   Wim is also a Microsoft MVP in the Azure category and a founding board member of the MC2MC user group. As a passionate community member, he regularly writes blogs and speaks about his daily experiences with Azure and other Microsoft technologies.