If you’re working with Logic Apps in Visual Studio 2019, you may have encountered an issue when deploying Azure resources using the Deploy-AzureResourceGroup.ps1 script.
This script might be using commands from the now-deprecated AzureRM module, causing errors when running your deployment.
Here’s how to resolve this issue by replacing the outdated AzureRM cmdlets with the newer Az module commands, ensuring your script works seamlessly.
Common Errors You Might Encounter:
sourceGroup.ps1: The term 'Get-AzureRmResourceGroup' is not recognized as the name of a cmdlet, function, script file, or operable program.
CommandNotFoundException, Deploy-AzureResourceGroup.ps1
Deploying template using PowerShell script failed.
Solution:
The AzureRM module has been deprecated, and Microsoft recommends using the Az module instead. Below is a list of cmdlet replacements that should resolve your deployment issues.
AzureRm (Deprecated) | Az Module | |
Get-AzureRmResourceGroup | ➡️ | Get-AzResourceGroup |
New-AzureRmResourceGroup | ➡️ | New-AzResourceGroup |
Get-AzureRmStorageAccount | ➡️ | Get-AzStorageAccount |
New-AzureRmStorageAccount | ➡️ | New-AzStorageAccount |
New-AzureStorageContainer | ➡️ | New-AzStorageContainer |
Set-AzureStorageBlobContent | ➡️ | Set-AzStorageBlobContent |
New-AzureStorageContainerSASToken | ➡️ | New-AzStorageContainerSASToken |
(Get-AzureRmContext).Subscription.SubscriptionId | ➡️ | (Get-AzContext).Subscription.Id |
BlobEndPoint | ➡️ | BlobEndpoint |
New-AzureRmResourceGroupDeployment | ➡️ | New-AzResourceGroupDeployment |
Install the Az Module: First, make sure you have the Az module installed on your system. You can install it using the following PowerShell command:
Install-Module -Name Az -AllowClobber -Force -Scope CurrentUser
Update the Deploy-AzureResourceGroup.ps1 Script: Open the Deploy-AzureResourceGroup.ps1 file in your project and replace the AzureRM cmdlets with the corresponding Az module cmdlets
After replacing the commands, save the file and try running the script again. Your deployment should now work without encountering the errors related to the AzureRM cmdlets.
To lazy to read? We’ve got you covered! Check out our video version of this content!
Hope you find this helpful! If you enjoyed the content or found it useful and wish to support our efforts to create more, you can contribute towards purchasing a Star Wars Lego for Sandro’s son!