Deploy Azure infrastructure by using JSON ARM templates
Implement JSON ARM template
Declare resources and add flexibility to your template by adding resources, parameters and outputs.
JSON ARM templates allow you to specify your projects infrastructure in a declarative and reusable way. You can version and save the templates in the same source control as your development project.
Bicep is a language for defining your azure resources. It has simpler authoring experience than JSON along with other features that help improve the quality of your infrastructure as code.
With infrastructure as code, you can maintain both your application code and everything you need to deploy application in a central code repository. The advantages to infrastructure as code are:
Consistent configurations
Improved scalability
Faster deployments
Better traceability
The declarative syntax is a way of building the structure and elements that outline what resources will look like without describing the control flow. Declarative syntax is different that imperative syntax, which uses commands for the computer to perform. Imperative syntax focuses on specifying each step in deploying the resources.
ARM templates allow you to automate deployments and use the practice of infrastructure as code. The template code becomes part of your infrastructure and development projects. Just like application code, you can store the IaC files in a source repository and version them.
ARM templates are idempotent which means you can deploy the same template many times and get the same resource types in the same state.
Resource Manager orchestrates deploying the resources so they are created in correct order. When possible, resources will also be created in parallel. So ARM template deployments finish faster than scripted deployments.
Resource manager also has built-in validation. It checks the template before starting the deployment to make sure the deployment will succeed.
If your deployments become more complex, you can break your ARM templates into smaller, reusable components. You can link these smaller templates together at deployment time. You can also nest templates inside other templates
ARM template file structure
Schema
defines the location of the JSON schema file that describes the structure of JSON data.
Yes
contentVersion
defines the version of your template.
Yes
apiProfile
defines the collection of API versions of resource types. You can use this value to avoid having to specify API versions for each resource in the tempalte
No
parameters
section where we can define values that are provided during resource types.
No
variables
define values that are used to simplify template language expressions
No
functions
define user-defined functions that are available within the template.
No
resources
defines the actual items you want to deploy or update in a resource group or a subscription
Yes
output
specify the values that will be returned at the end of deployment
No
You can deploy an ARM template to azure via
Deploy a local template
Deploy a linked template
Deploy in a continuous deployment pipeline
The difference between
az deployment group create
andaz group deployment create
is thataz group deployment create
is an old command to be deprecated and will be replaced byaz deployment group create
. Therefore it is recommended usingaz deployment group create
to deploy resources under the resource group scope
Use linked templates to deploy complex solutions. You can break a template into many templates and deploy these templates through a main template. When you deploy the main template, it triggers the linked template's deployment. You can store and secure the linked template by using a SAS token.
To add a resource to your template, you will need to know the resource provider and its types of resources. The syntax for this combination is in the form {resource-provider}/{resource-type} For example, to add a storage account resource to your template, you will need the "Microsoft.Storage" resource provider. One of the types for this provider is "storageAccount". So your resource type will be displayed as Microsoft.Storage/storageAccounts.
Last updated