When deploying infrastructure to Azure using ARM templates, you have two deployment models to choose from, incremental and full deployments.
Incremental deployments add new resources to your existing environment, while full deployments replace all existing resources with new ones. Incremental deployments are best suited when you need to add new resources to an existing environment without affecting the existing resources. For example, you can use an incremental deployment to add a new virtual machine to your environment.
On the other hand, full deployments are helpful when creating an entirely new environment, including all resources. For instance, a full deployment can be helpful when you want to start fresh or move to a new location. However, full deployments can be risky as they delete and replace the previous environment with a new one.
In Bicep, you can use incremental deployments to add new resources to your existing environment. For instance, here’s an example of an incremental deployment using Bicep:
# Azure PowerShell # New-AzResourceGroupDeployment -ResourceGroupName MyResourceGroup -TemplateFile main.bicep -Mode Incremental # Azure CLI # az group deployment create -g MyResourceGroup --template-file main.bicep --mode Incremental
The parameter -Mode followed by the value Incremental will issue an incremental deployment. This is also the default value when issuing a new deployment.
Similarly, you can use full deployments to create a new environment from scratch in Bicep. Here’s an example of a full deployment using Bicep:
# Azure PowerShell # New-AzResourceGroupDeployment -ResourceGroupName MyResourceGroup -TemplateFile main.bicep -Mode Complete # Azure CLI # az group deployment create -g MyResourceGroup --template-file main.bicep --mode Complete
The parameter -Mode followed by the value Complete will issue a full deployment.
Overall, it’s crucial to consider your specific requirements and choose the appropriate deployment model to ensure a successful deployment. Failure to choose the right deployment model can result in issues such as overwriting or deleting existing resources. Therefore, it’s important to understand the differences between the two deployment models and select the one that best fits your needs.