Iac - knowlesy/AZ400 GitHub Wiki
**Declarative ** (functional). The declarative approach states what the final state should be. When run, the script or definition will initialize or configure the machine to have the finished state declared without defining how that final state should be achieved.
**Imperative ** (procedural). In the imperative approach, the script states the how for the final state of the machine by executing the steps to get to the finished state. It defines what the final state needs to be but also includes how to achieve that final state. It also can consist of coding concepts such as for, *if-then, loops, and matrices.
The declarative approach abstracts away the methodology of how a state is achieved. As such, it can be easier to read and understand what is being done.
It also makes it easier to write and define. Declarative approaches also separate the final desired state and the coding required to achieve that state.
Idempotence is a mathematical term that can be used in Infrastructure as Code and Configuration as Code. It can apply one or more operations against a resource, resulting in the same outcome.
For example, running a script on a system should have the same outcome despite the number of times you execute the script. It shouldn't error out or do the same actions irrespective of the environment's starting state. You can achieve idempotency by:
Automatically configuring and reconfiguring an existing set of resources. Discarding the existing resources and recreating a new environment
Arm TEMPLATES
Deployments modes
When deploying your resources using templates, you have three options:
- validate. This option compiles the templates, validates the deployment, ensures the template is functional (for example, no circular dependencies), and correct syntax.
- **incremental mode **(default). This option only deploys whatever is defined in the template. It doesn't remove or modify any resources that aren't defined in the template. For example, if you've deployed a VM via template and then renamed the VM in the template, the first VM deployed will remain after the template is rerun. It's the default mode.
- complete mode: Resource Manager deletes resources that exist in the resource group but isn't specified in the template. For example, only resources defined in the template will be present in the resource group after the template deploys. As a best practice, use this mode for production environments to achieve idempotency in your deployment templates.