AZ-104 Step by step

Deploy Azure Infrastructure with ARM Templates: AZ-104

AZ-104 how-to: write and deploy a JSON ARM template in VS Code that creates a storage account, then add parameters, allowed values and output endpoints.

· 6 min read

Thumbnail of the lesson: Deploy Azure infrastructure by using JSON ARM templates
Watch the lesson: Deploy Azure infrastructure by using JSON ARM templates | Prerequisite… | AZ-104 Azure Administrator

Deploy Azure infrastructure by using JSON ARM templates is the AZ-104 lesson where you write and deploy your first Azure Resource Manager template. It is for Azure administrator learners who want to stop clicking through the portal and start deploying infrastructure as code, and it builds a template that creates a storage account, complete with parameters and outputs.

At about 49 minutes, this is the longest lesson in the free AZ-104 Azure Administrator course. It assumes you already have an Azure subscription, Visual Studio Code and the Azure Resource Manager tools extension set up, and it uses the Azure CLI or Azure PowerShell to deploy.

What this lesson covers

The video covers 12 areas, moving from theory to a working template:

  • What an ARM template is. A JSON file that defines your Azure infrastructure in a declarative, reusable way. Declarative means you describe the end result, and Azure Resource Manager works out the order of the API calls to create it.
  • Template sections. The schema and content version are required declarations, the resources section is the core, and parameters, variables, functions and outputs are the other sections you will use.
  • Deploying a template. The recommended commands are az deployment group create for the Azure CLI and New-AzResourceGroupDeployment for Azure PowerShell, run against a resource group.
  • Parameters. A parameter can have a type, a default value, a list of allowed values and constraints such as minimum and maximum length.
  • Outputs. Values returned after deployment. In the lesson, the output uses the reference function to return the new storage account’s primary endpoints.
  • Exam checks on the deployment command, template elements and idempotency.

What you will do

These are the steps the instructor takes in the video, in order, with the moment each one starts. Watch the video for the full walkthrough.

  1. Let’s start exploring the structure of an ARM template. In this unit, we’ll see how these templates implement infrastructure as code. We’ll survey the different sections that make up a template file, learn the methods for … (3:23)
  2. Let’s start by creating the template file itself. (17:06)
  3. Open a new terminal by going to terminal and then new terminal. The critical check here is your shell. If the command bar says bash, you’re in the right place and can move on. If it says something else like PowerShell, you need to change … (18:39)
  4. Select the deployment name. In this case, it’s called blank template. (25:07)
  5. Select the link showing the count of successful deployments. (27:11)
  6. We add a new parameter called storage name. We define its type as string and set a min length of three and a max length of 24 which enforces Azure’s naming rules right in the template. We also add a metadata description to guide … (33:58)
  7. Now we deploy the updated template. The command is nearly identical to before, but we change the deployment name to add parameter plus today’s date to better reflect what this deployment does. The crucial difference is we now pass the … (34:39)
  8. We set its type to string and give it a default value of standard LRS. (36:24)
  9. Run one of these, replacing the placeholder with your actual unique string. (39:16)
  10. You can choose the option that fits you best, either a pay as you go subscription or a free trial that’s available for up to 30 days. Signing up gives you access to start deploying and managing resources like the ones we’ve … (40:27)
  11. You can configure the default location using a configure defaults location equals the command is agroup create. (46:39)
  12. You can configure the default location using a configure defaults location equals the command is new a resource group. To start a template deployment at the resource group, use either the Azure CLA command a deployment group create or … (47:08)
  13. Copy and paste the following code into the file. Notice that this file has all of the sections of an ARM template that we described in the previous unit. (48:46)

Where it fits in the AZ-104 course

This is video 3 of 30. It comes right after Introduction to Azure Cloud Shell, which gives you a command line for Azure, and before Understand Microsoft Entra ID, which starts the identity and governance section.

Later lessons, such as Introduction to Azure virtual machines, return to deploying resources from templates.

How to study this lesson

  1. Prepare your tools first: an Azure subscription, VS Code with the Azure Resource Manager tools extension, and the Azure CLI or Azure PowerShell.
  2. Watch the theory part, noting which template sections are required.
  3. Create the template file and open a terminal in VS Code. As the video shows, check your shell; the lesson uses Bash.
  4. Deploy the blank template to a resource group, then find the deployment in the portal and open the deployment history.
  5. Add the storage account resource and deploy again.
  6. Add the storage name parameter with a minimum length of 3 and a maximum of 24, then the SKU parameter with a default of Standard_LRS and a list of allowed values. Try deploying a value that is not allowed and read the error.
  7. Add the output for the storage endpoints and check the values returned after deployment.
  8. Clean up. Delete the resource group you used so nothing keeps running.

After the lesson, the AZ-104 mock exam is a good way to check your understanding across the whole course; it has a free 10-question sample.

Frequently asked questions

What does idempotent mean for ARM templates?

The lesson explains that you can deploy the same template to the same environment many times and always get the same resource state.

Should I learn Bicep or JSON ARM templates?

The video says Bicep is recommended for new authoring because it is simpler, but the JSON structure is still worth understanding, especially for the AZ-104 exam. This lesson teaches the JSON format.

Which command deploys an ARM template to a resource group?

In the lesson, you use az deployment group create with the Azure CLI, or New-AzResourceGroupDeployment with Azure PowerShell, pointing at your template file and a resource group.

Is this lesson free?

Yes. The lesson and all 30 videos of the course are free on YouTube. Follow them in order from the AZ-104 course page.

Do it yourself

Lab guides, practice and full mock exams come with a subscription. See the plans