Member-only story
TECH BASICS
Introduction to Azure Bicep: Part 2
Azure | Cloud | IaC | DevOps | Automation
Before we move on, here is the link for part-1 — https://arunksingh16.medium.com/introduction-to-azure-bicep-part-1-902ccf2b260e
In previous post we talked about very basic stuff in respect to bicep. In this post I will try to cover few more concepts which is required to understand Bicep. If you are coming from Terraform background then the questions you may think of state, modules, templates extra. Let’s find out answers for those.
Bicep and Immutability
With Bicep, when a new deployment is executed, it creates a new set of resources based on the desired state defined in the code. If there are any changes to the code or desired state, a new deployment is executed to create a new set of resources. The previous resources are not modified, but they are replaced with new ones. This approach has several advantages, such as ensuring consistency, reliability, and predictability of the infrastructure.
How Bicep maintains the state?
Bicep does not maintain the state of resources on its own. Instead, it is used to create, update, or delete Azure resources using Azure Resource Manager (ARM) templates. The state of the resources is maintained by Azure Resource Manager (ARM) which is the deployment and management service for Azure resources.
When you use Bicep to create or update an Azure resource, it generates an ARM template based on the Bicep code you have written. The generated ARM template is then used to make the actual deployment to Azure.
Once the deployment is successful, ARM tracks the state of the resources that have been deployed and makes sure that they stay in the desired state. If any changes are made to the resources outside of the ARM deployment process (e.g. via the Azure portal), ARM will detect the changes and prompt you to either redeploy the updated state or discard the changes.
In summary, Bicep is used to define the desired state of Azure resources, and ARM ensures that the resources stay in that state by applying the changes defined in the ARM templates generated by Bicep.