From the course: Microsoft Azure DevOps Engineer Expert (AZ-400) Cert Prep by Microsoft Press
Understand infrastructure as code - Azure Tutorial
From the course: Microsoft Azure DevOps Engineer Expert (AZ-400) Cert Prep by Microsoft Press
Understand infrastructure as code
The concept of using code to provision infrastructure and automate deployments is known as infrastructure as code. There are many tools that can be used for infrastructure as code. And one of the most well-known tools in this space is Terraform. And one of its advantages is that it works with multiple Cloud providers. Another tool that we can use are the Azure Resource Manager templates. They're Microsoft's proprietary infrastructure as code solution for Azure. They are based on JavaScript object notation and use a declarative syntax, meaning that in these files you state what you intend to create and the properties for these resources, And resource manager will take care of creating them without you having to write a sequence of programming commands in order to have them created. Besides creating infrastructure, you can also manage, update and delete Azure Resources with Azure Resource Manager templates. There are four levels of scopes with the lowest being the resource group and the highest being the tenant. This means that resources in resource groups inherit settings from subscriptions, subscriptions from management groups and management groups from the tenant. To understand Azure Resource Manager templates, it is important to understand some basic JavaScript object notation concepts. To start out, the allowed data types are string, number, object, array, Boolean, and null. Data is represented as name and value pairs where each pair is separated by a comma as you can see in the example to the left. In order to define an array, you must use square brackets, and within the brackets you separate every element of the array with a comma. In the example to the left, you can see that we have an array with three elements. Be mindful of the last element as that one should not have a comma, otherwise this will cause an error. You can also declare objects with the use of curly braces. Within the object you can have strings, arrays, as well as another object. In the example to the left, you can see that we have an object name with a name and value pair as well as an array. An ARM template is made up of the following elements of which schema, content version, and resources are required elements that we must define in the template while the other five are optional. The schema defines the location of your JSON schema file. This file describes the properties available within the template. Content version specifies the version of your template. You can use it to document changes made to your template. Resources is a block of code where you will be defining the resources that you want to deploy or update. And next, we have the optional elements such as parameters where we can define values that can be provided by the command line or a parameter file, variables that can help us simplify the template by not having to write values over and over, functions that can help you simplify your template in case you have any complicated expressions, outputs which return values at the end of the deployment, and API profile to define API versions for each resource in the template. In the block of code to the left, you can see a basic example of an ARM template. You can see the value for the schema, which points to a link in Azure, a value for content version, and in this case resources is empty as no resources have been defined yet. Besides the main or parent ARM template as it is also called, we can integrate nested and linked templates. The nested template is basically just another template that is embedded into the parent template. It is added within the resources element of the parent template. In the example to the left, you can see that this whole block of code is part of the resources element. In this case, the resources element would be a part of a parent template, which is not shown in this example. An important part of this template is a type of resource which is of type deployment as we are creating a nested template. Next, we have the properties object where we have the type of mode which is incremental in this example, meaning that resources will be created without deleting existing resources that are not included in the nested template followed by a template object and its elements and resources. The linked template, on the other hand, is just a template that is referenced via a link from within the parent template. And just like the nested template, you add a deployment resource to the resources section of the parent template. And within the properties object, we define the template link object and within it either the U.R.I. or relative path to the linked template. In the example to the left, you can see that we are linking a template called linkedStorageAccount.json, which is located in a relative path to the parent ARM template. And finally, when we are ready to deploy our template, we can use PowerShell, Azure CLI, Cloud Shell or the Azure Portal as well as the REST API. I have shared some examples of the Azure CLI command as well as a PowerShell commands, as it is important to understand the difference between the two.
Contents
-
-
-
-
-
-
-
-
(Locked)
Learning objectives1m 45s
-
(Locked)
Learn about the application deployment process6m 49s
-
(Locked)
Lab A: Set up a release pipeline20m 3s
-
(Locked)
Lab B: Set dependencies, approvals, and gates11m 44s
-
Understand infrastructure as code6m 29s
-
(Locked)
Lab C: Deploy ARM templates19m 42s
-
(Locked)
Learn about configuration management3m 50s
-
(Locked)
Lab D: Use custom script extension10m 3s
-
(Locked)
Lab E: Configure desired state configuration11m 52s
-
(Locked)
Lab F: Set up automation state configuration9m 57s
-
(Locked)
Learn about Azure app configuration1m 37s
-
(Locked)
Lab G: Learn about Azure app configuration3m 47s
-
(Locked)
-
-
-
-
-