Friday, February 3, 2023

PowerShell and Az CLI commands to deploy ARM and Bicep templates

 This is just a quick note on the PowerShell command to deploy ARM templates.

Command should be run from the location where the ARM templates are located (or update the file path).

New-AzResourceGroupDeployment -Name deploy_storage_account -ResourceGroupName rg-some_resource_group-001 `

  -TemplateFile .\deploy_storage_account.json `

  -TemplateParameterFile .\deploy_storage_account.parameters.json

There is another example here for deploying a key vault.

And here's link to the Microsoft documentation.

For Az CLI the command format is:

az deployment group create --resource-group <resource-group-name> --template-file <path-to-bicep> --parameters <path-to-bicepparam>


What-if

You can also run what-if, which can be very useful for verifying what will change before running the actual deployment:

New-AzResourceGroupDeployment -WhatIf -Name deploy_storage_account -ResourceGroupName rg-some_resource_group-001 `

  -TemplateFile .\deploy_storage_account.json `

  -TemplateParameterFile .\deploy_storage_account.parameters.json


az deployment group what-if --resource-group <resource-group-name> --template-file <path-to-bicep> --parameters <path-to-bicepparam>

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.