Introduction
In my ongoing journey to become an Azure Administrator, I recently completed Lab 03 - Manage Azure Resources by Using Azure Resource Manager (ARM) Templates from the AZ-104 certification series. This lab focused on automating resource deployments using both ARM templates and Bicep templates.
By completing this lab, I learned how to create, deploy, and manage resources in Azure using templates, which enhances efficiency, reduces human error, and ensures consistency across environments. Below, I document my key learnings, insights, and the steps I followed throughout this lab.
Lab Overview
This lab was designed to provide hands-on experience with deploying resources in Azure using Azure Resource Manager templates and Bicep templates. The goal was to automate and simplify the deployment of resources like managed disks and virtual machines, improving operational efficiency.
Skills Practiced:
✅ Creating and configuring Azure Resource Manager (ARM) templates
✅ Editing and redeploying ARM templates
✅ Deploying templates using Azure PowerShell and Azure CLI
✅ Using Bicep templates for resource deployment
✅ Automating resource management in Azure
Task 1: Create an Azure Resource Manager Template
The first task involved creating a managed disk in Azure using the Azure portal. Once the disk was created, I exported the deployment template to use for future deployments. Here's what I did:
1️⃣ Signed into the Azure portal – Azure Portal.
2️⃣ Navigated to "Disks" and created a new managed disk with the following settings:
Disk Name: az104-disk1
Region: East US
Disk Size: 32 GiB
Performance: Standard HDD
3️⃣ Once the disk was deployed, I navigated to the "Automation" blade and selected "Export template."
4️⃣ Downloaded the template and parameters files, which were in JSON format, and extracted them for later use.
📌 Insight:
Exporting templates from existing resources is a powerful way to automate the deployment of similar resources, ensuring consistency and saving time when scaling infrastructure.
Task 2: Edit an Azure Resource Manager Template and Redeploy
In this task, I used the downloaded ARM template to deploy a new managed disk by editing the template. Here's what I did:
1️⃣ Went to the Azure portal and selected "Deploy a custom template."
2️⃣ Loaded the previously downloaded template into the editor and modified the disk name from az104-disk1 to az104-disk2.
3️⃣ Edited the parameters file to match the template changes, specifically changing disks_az104_disk1_name to disk_name.
4️⃣ Deployed the updated template to the same resource group.
5️⃣ Verified the creation of az104-disk2 by reviewing the resource group in the portal.
📌 Insight:
Modifying and redeploying templates is an excellent way to quickly replicate configurations and maintain consistency across multiple deployments. This process is highly beneficial when managing environments with many resources.
Task 3: Deploy a Template with Azure PowerShell
This task focused on deploying the template using Azure PowerShell in the Cloud Shell. I used PowerShell to automate the deployment of the managed disk. Here's what I did:
1️⃣ Opened Azure Cloud Shell and selected PowerShell as the shell experience.
2️⃣ Mounted the Cloud Shell storage and uploaded the template and parameters files.
3️⃣ Used the following PowerShell command to deploy the template:
powershell
New-AzResourceGroupDeployment -ResourceGroupName az104-rg3 -TemplateFile template.json -TemplateParameterFile parameters.json
4️⃣ Confirmed that the disk was created successfully using the Get-AzDisk command.
📌 Insight:
Using Azure PowerShell provides a powerful and flexible way to automate resource deployments, and it is especially useful for managing complex deployments that involve multiple resources.
Task 4: Deploy a Template with the CLI
In this task, I deployed the ARM template using Azure CLI, which is another powerful tool for managing Azure resources. Here’s what I did:
1️⃣ Opened Cloud Shell and switched to the Bash environment.
2️⃣ Uploaded the template and parameters files.
3️⃣ Used the following CLI command to deploy the managed disk:
bash
az deployment group create --resource-group az104-rg3 --template-file template.json --parameters parameters.json
4️⃣ Verified that the disk was created successfully by running the command:
bash
az disk list --output table
📌 Insight:
The Azure CLI is an excellent tool for automating deployments and is often preferred by developers and IT professionals familiar with Linux-based systems. It offers a scriptable interface for creating and managing Azure resources.
Task 5: Deploy a Resource Using Azure Bicep
The final task involved using Bicep, a declarative language built on top of ARM templates, to deploy a managed disk. Here's what I did:
1️⃣ Downloaded the Bicep template for creating a managed disk (azuredeploydisk.bicep).
2️⃣ Uploaded the Bicep file to Cloud Shell and edited it to change the disk name and size.
3️⃣ Deployed the Bicep template using the following CLI command:
bash
az deployment group create --resource-group az104-rg3 --template-file azuredeploydisk.bicep
4️⃣ Confirmed the disk creation with the following command:
bash
az disk list --output table
📌 Insight:
Bicep simplifies the authoring of infrastructure-as-code by offering a cleaner syntax and better readability compared to traditional ARM JSON templates. It is a great option for those looking for a more streamlined and developer-friendly tool for managing Azure resources.
Key Learnings
1️⃣ ARM Templates for Resource Management
ARM templates allow you to manage infrastructure as code, defining the structure and configuration of resources in a declarative way. Templates can be exported, edited, and redeployed easily, which makes managing large-scale Azure environments more efficient.
2️⃣ Automation with PowerShell and CLI
Using Azure PowerShell and CLI for deploying templates enhances automation and reduces manual intervention. Both tools integrate well with Azure, providing a flexible and scalable approach to managing resources.
3️⃣ Bicep as an Alternative to ARM Templates
Bicep is an alternative to ARM templates, offering a more concise and readable syntax. It supports all the capabilities of ARM templates but in a more user-friendly format.
4️⃣ Consistency and Reliability
Automating deployments with templates ensures that resources are deployed consistently across different environments, reducing the risk of errors and increasing reliability.
Conclusion
Completing this lab strengthened my understanding of Azure Resource Manager templates and how they can be used to automate and simplify resource deployments. By learning how to use ARM templates, Azure PowerShell, Azure CLI, and Bicep, I gained valuable experience in managing Azure resources efficiently and consistently. These skills are essential for optimizing resource management in real-world Azure environments.
🚀 Stay tuned for my next blog post on Lab 08 - Managing Virtual Machines in Azure!
🔗 Follow my journey as I continue mastering Azure Administration! 🚀
Top comments (0)