Troubleshooting ERROR: The subscription is not registered to use namespace ‘Microsoft.ContainerInstance’.

While trying to create the Azure Container Instances on one of the newly created Azure Subscription, we came across this strange error, “ERROR: The subscription is not registered to use namespace ‘Microsoft.ContainerInstance'”. So we checked our configuration and the way we were creating the Azure Containers, and it all seemed okay. So we dig a little around by using PowerShell, authenticate to Azure using Login-AzureRmAccount and fire few commands.

The first command we fired was classic Get-Command to check if there are any existing cmdlets to help with Azure Resources and sure enough, there it was:

check if there are any commands to help with resources provisioning

Next, is to obviously run it against the newly created subscription. But first we needed to know how the cmdlet works or what parameters it accepts. To that, Get-Help cmdlet came in as rescue:

checking parameters for the cmdlet

Sure enough, there is no parameter which accepts subscription name or id as value. But it looks like it can run against current Azure Context. So, we can set the current azure context to newly created subscription by using cmdlet Set-AzureRmContext. And, then we can run above command to see existing list of resources:

Get-AzureRmResourceProvider -ListAvailable

The output is a little long to fit on one screen. So we needed to format it in tabular mode and scroll down a little to check for resource provider named Microsoft.ContainerInstances:

container instance not registered

Now, we can run the below command to run the registration:

Register-AzureRmResourceProvider -ProviderNamespace Microsoft.ContainerInstance

We’ll need to wait for a couple of minutes before the registration completes. After this, if we run the Get-AzureRmResourceProvider cmdlet again, it should show as registered:

container instance registered

There it goes. If we wanted to use this using azure cli commands, we can run like below command:

az provider register –namespace Microsoft.ContainerInstance

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s