AZ-104 Microsoft Azure Administrator Exam

You're a great admin... on-prem. Now, become a great admin in the cloud and prove it by passing the Microsoft Certified: Azure Administrator Associate exam!

Practice Test

Exam

Automate deployment of resources by using Azure Resource Managertemplates or Bicep files

Interpret an Azure Resource Manager template or a Bicep file

An Azure Resource Manager template is a JSON file that describes the infrastructure and configuration for Azure resources. A Bicep file uses a domain-specific language to achieve the same goal with cleaner syntax. Both formats let you define parameters, variables, resources, and outputs to automate deployments.

Every template or Bicep file has four main sections: parameters, variables, resources, and outputs. Parameters let you pass values at deployment time. Variables store reusable values inside the template. Resources define the items you want to deploy, and outputs return information after deployment.

In Bicep files, the syntax is more concise than JSON. For example, you declare parameters with a simple param keyword instead of a long JSON object. This reduces the risk of syntax errors and makes it easier to read and maintain large templates.

To interpret either file, you use tools like Visual Studio Code with the Azure Resource Manager Tools extension. This extension provides IntelliSense, validation, and a visual template visualizer. Understanding the structure and using these tools are important steps before you deploy any template or Bicep file.

Modify an existing Azure Resource Manager template

When you need to update an ARM template, you first locate the parameters and variables you want to change. For example, you might adjust the default value of a storageAccountType parameter or add a new adminUsername variable.

Next, you edit the resources section to add, remove, or update resource definitions. You can change properties like location, sku, or tags to meet new requirements. It’s important to keep resource dependencies in mind so that deployments occur in the correct order.

You may also need to update the outputs section to return new values after deployment. For instance, you could output the connection string of a storage account. Validating your changes with Test-AzResourceGroupDeployment or az deployment group validate helps catch errors before you apply them.

Finally, use deployment modes like Incremental or Complete to control how Azure handles existing resources. Incremental mode adds or updates resources without removing others, while Complete mode deletes resources not in the template. Choosing the right mode prevents accidental resource deletion.

Modify an existing Bicep file

A Bicep file uses the param and var keywords to declare parameters and variables more succinctly than JSON. When modifying a file, you locate the param declarations to adjust input values, such as VM size or admin credentials.

To change resource definitions, you edit the resource blocks directly. For example, you might add a new storage account or update the SKU on an existing resource. Bicep’s cleaner syntax makes it easier to spot errors and understand the structure at a glance.

Bicep supports modules for reusability, letting you break complex deployments into smaller files. You can update module references or pass new parameters into modules to extend functionality. This modular approach helps keep large deployments organized.

After making changes, run bicep build to transpile your Bicep file into an ARM template. This process reveals any syntax issues and produces a JSON file ready for deployment. Using the Bicep CLI ensures that your code remains valid before you run a deployment command.

Deploy resources by using an Azure Resource Manager template or a Bicep file

You can deploy an ARM template or Bicep file using the Azure portal, Azure CLI, or PowerShell. In the portal, navigate to your resource group and use the Deploy a custom template option. With the CLI, run az deployment group create --template-file <file>.

PowerShell offers the New-AzResourceGroupDeployment cmdlet to deploy templates. You specify the template path and any parameter values. Both CLI and PowerShell support incremental and complete deployment modes to control resource modifications.

Templates and Bicep files can target different scopes: resource group, subscription, management group, or tenant. You choose the scope by using flags like --scope subscription in CLI or -Scope ManagementGroup in PowerShell. Selecting the correct scope ensures resources are deployed where you intend.

After submission, Azure performs a what-if operation when you use --what-if in CLI or WhatIf in PowerShell. This shows you changes without making them. Reviewing the what-if results helps you avoid unintended modifications before you finalize the deployment.

Export a deployment as an Azure Resource Manager template or convert an Azure Resource Manager template to a Bicep file

To export an existing deployment as an ARM template, go to the Azure portal’s resource group and open Automation script. This generates a JSON template that represents the current state of your resources. You can then download it for customization.

Alternatively, use PowerShell’s Export-AzResourceGroup cmdlet to generate a template programmatically. This approach is useful for scripting and automated workflows. Exporting templates gives you a baseline that matches exactly what is deployed.

Converting an ARM template to a Bicep file uses the bicep decompile command. This transforms the JSON into Bicep syntax, making the file easier to maintain. After conversion, you should review the Bicep file to remove any hard-coded values and replace them with parameters.

Once you have the Bicep version, run bicep build to confirm validity. You may need to refine parameter types or default values for better reusability. Refining the output ensures your Bicep files remain clean, modular, and ready for future automation.

Conclusion

Automating deployments with Azure Resource Manager templates and Bicep files brings consistency, repeatability, and version control to your Azure infrastructure. Understanding how to interpret and modify templates or Bicep files helps you adapt to changing requirements quickly. Deploying through CLI, PowerShell, or the portal is straightforward when you know the commands and deployment modes. Finally, exporting existing deployments and converting templates to Bicep files give you a solid starting point for infrastructure as code. These skills are essential for any Azure administrator aiming to streamline resource management.

Study Guides for Sub-Sections

Azure Resource Manager (ARM) templates are pivotal in automating the deployment and management of Azure resources. They are JSON files that use declarative syntax, allowin...

ARM templates and Bicep files are essential tools for deploying resources in Azure. They serve the purpose of defining infrastructure and configuration in a way th...

Bicep diagnostic code BCP170 is important when you're working with child resources in a Bicep file. This diagnostic highlights an issue if you use a fully qualifie...

Azure Resource Manager (ARM) templates are essential tools for managing and deploying resources in Azure. They are JSON files that use declarative syntax ...

Azure Resource Manager (ARM) templates are JSON files that define the infrastructure and configuration for your Azure projects. They use declarative syntax, allowing you t...