Using Az module with Visual Studio Azure resource group projects

I recently uninstalled the AzureRM PowerShell module to upgrade to the AZ module. In doing so I can no longer deploy using the generated PowerShell script of Resource Group projects in Visual Studio. In this post I will explain how to upgrade your scripts to use the new AZ module.

If you attempt to run the script as is, you will get the following error.

The term 'New-AzureRmResourceGroup' is not recognized
as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.

Below is a mapping of the old and new Cmdlet names as they appear in the Deploy-AzureResourceGroup.ps1:

Old Name

New Name

Publish-AzureRmVMDscConfiguration

Publish-AzVMDscConfiguration

Get-AzureRmContext

Get-AzContext

Get-AzureRmStorageAccount

Get-AzStorageAccount

New-AzureRmResourceGroup

New-AzResourceGroup

New-AzureRmStorageAccount

New-AzStorageAccount

New-AzureStorageContainer

New-AzStorageContainer

Set-AzureStorageBlobContent

Set-AzStorageBlobContent

New-AzureStorageContainerSASToken

New-AzStorageContainerSASToken

Test-AzureRmResourceGroupDeployment

Test-AzResourceGroupDeployment

New-AzureRmResourceGroupDeployment

New-AzResourceGroupDeployment

Notice it is not just a global find and replace of “AzureRM” to “Az”. Some of the Cmdlets use the noun “Azure” instead of “AzureRM” for example “New-AzureStorageContainer”.

You can make all the mentioned substitutions or simply use this GitHubGist instead

Comments (1) -

  • Andy

    5/1/2019 10:50:46 PM | Reply

    This is a useful reminder to rename AzureRM references when you switch to using the new Az module, unfortunately it doesn't appear to resolve the problem; presumably as Visual Studio is referencing the older modules in its own code too.  I'm using VS Enterprise 2017 and although some of the errors changed when I updated Deploy-AzureResourceGroup.ps1, it still doesn't work.

Add comment

Loading