Error "(NoRegisteredProviderFound) No registered resource provider found for location 'global' and API version '2023-07-01-preview' for type 'dnszones'. "

Last week, I encountered the following error while attempting to upload a DNS Zone file to an Azure DNS Zone through the Az Module. This happened in both Cloud Shell and PowerShell: Code: NoRegisteredProviderFoundMessage: No registered reso

AI-assisted translation, approved by Mateo.

Last week, I encountered the following error while attempting to upload a DNS Zone file to an Azure DNS Zone through the Az Module. This happened in both Cloud Shell and PowerShell:

Code: NoRegisteredProviderFound
Message: No registered resource provider found for location {location}
and API version {api-version} for type {resource-type}.

First, we must ensure that the provider we are using is registered. In this case, for dnszones, the provider is Network.

  • az provider list --output table
  • az provider show --namespace Microsoft.network --output table
  • az provider show --namespace Microsoft.Network --query "resourceTypes[?resourceType=='dnszones']"

Searching the web, I was able to find several Issues reported to MS:

According to the issues, the problem is in the MS Backend.

Workaround

For now, there is no definitive solution to the issue. The proposed workaround is to downgrade the Azure CLI version.

In this case, I installed the version on a virtual machine and was able to execute the change.

Invoke-WebRequest -Uri https://azurecliprod.blob.core.windows.net/msi/azure-cli-2.30.0.msi -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi

After doing this, I was able to execute the operation that had previously failed.

In this case, it was a fairly simple scenario; certain complexities may arise in larger-scale scenarios in Azure DevOps or GitHub Actions.

These are examples for the modification in Azure DevOps and GitHub Actions added by contributors in the GitHub cases:

PowerShell
- task: PowerShell@2
displayName: 'Revert to az cli version 2.49.0'
inputs:
targetType: 'inline'
pwsh: true
script: |
pip install -Iv azure-cli==2.49.0 --extra-index-url https://azurecliprod.blob.core.windows.net/edge
Bash
- name: Install Azure cli
run: |
sudo apt-get install ca-certificates curl apt-transport-https lsb-release gnupg
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/trusted.gpg.d/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
sudo apt-get update
sudo apt-get install --allow-downgrades azure-cli=2.49.0-1~jammy

Thanks for reading. The learning continues in the next article.