# Lab 03: Managing Azure Resources with ARM and Bicep Templates

visit [microsoft learn github](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/ManagedAppMenuBlade/~/Users/appId/8a4ff89a-5105-446c-8a2b-e24799cc34cc/objectId/47dca9c4-5216-4d51-8577-9c49c1e32703) for complete instructions

This lab teaches you to automate Azure deployments using ARM and Bicep templates. You'll learn to create, edit, and deploy them using the Azure portal, PowerShell, and CLI.

### Interactive Simulations

Optional simulations to reinforce your understanding:

* [**Manage resources with ARM templates**](https://mslabs.cloudguides.com/guides/AZ-104%20Exam%20Guide%20-%20Microsoft%20Azure%20Administrator%20Exercise%205)**:** Create and deploy managed disks.
    
* [**Create a VM with a template**](https://mslearn.cloudguides.com/en-us/guides/AZ-900%20Exam%20Guide%20-%20Azure%20Fundamentals%20Exercise%209)**:** Deploy a VM using a Quickstart template.
    

### Lab Scenario

Your team wants to automate and simplify resource deployments to reduce administrative overhead, human error, and increase consistency.

![Diagram of the tasks.](https://github.com/MicrosoftLearning/AZ-104-MicrosoftAzureAdministrator/raw/master/Instructions/media/az104-lab03-architecture.png align="left")

### Tasks

1. **Create an ARM Template:** Create a managed disk and export its template.
    
2. **Edit and Redeploy:** Modify the template and redeploy to create another disk.
    
3. **Deploy with PowerShell:** Configure Cloud Shell and deploy the template using PowerShell.
    
4. **Deploy with CLI:** Deploy the template using CLI commands in Cloud Shell.
    
5. **Deploy with Bicep:** Use a Bicep file to deploy a managed disk.
    

### Task 1: Create an ARM Template

1. **Sign in to the Azure portal:** [https://portal.azure.com](https://portal.azure.com/) and **Navigate to:** Disks &gt; Create
    
2. **Create a managed disk (e.g.,** `az104-disk1` in East US).
    
3. **Go to the disk's resource &gt; Automation &gt; Export template.**
    
4. **Download the template and extract the two JSON files. (template and parameters file)**
    

### Task 2: Edit and Redeploy

1. **Search for "Deploy a custom template" in the portal.**
    
2. **Select "Build your own template in the editor".**
    
3. **Upload** `template.json` and modify it (e.g., change disk name to `az104-disk2`).
    
4. **Upload** `parameters.json` and update it to match the template.
    
5. **Deploy the template and verify the new disk is created.**
    

### Task 3: Deploy with PowerShell

1. **Open Cloud Shell in the Azure portal and select PowerShell.**
    
2. **Mount a storage account and upload the template files.**
    
3. **Edit** `template.json` in the Cloud Shell editor (e.g., change disk name to `az104-disk3`).
    
4. **Run the following command to deploy:**
    

PowerShell

```powershell
New-AzResourceGroupDeployment -ResourceGroupName az104-rg3 -TemplateFile template.json -TemplateParameterFile parameters.json
```

5. **Verify the disk is created using** `Get-AzDisk`.
    

### Task 4: Deploy with CLI

1. **Switch to Bash in Cloud Shell.**
    
2. **Edit** `template.json` (e.g., change disk name to `az104-disk4`).
    
3. **Run the following command to deploy:**
    

Bash

```powershell
az deployment group create --resource-group az104-rg3 --template-file template.json --parameters parameters.json
```

4. **Verify the disk is created using** `az disk list --output table`.
    

### Task 5: Deploy with Bicep

1. **Stay in Bash in Cloud Shell.**
    
2. **Upload the** `azuredeploydisk.bicep` file.
    
3. **Edit the Bicep file and make changes (e.g., change disk name, SKU, size).**
    
4. **Run the following command to deploy:**
    

Bash

```powershell
az deployment group create --resource-group az104-rg3 --template-file azuredeploydisk.bicep
```

5. **Verify the disk is created.**
    

### Cleanup

Delete the resource group to avoid unnecessary costs.

### Extend Your Learning

Use Copilot in Edge or copilot.microsoft.com to explore further:

* ARM template format and components
    
* Using existing ARM templates
    
* Comparing ARM and Bicep templates
    

### Key Takeaways

* ARM templates enable managing infrastructure as a group.
    
* ARM templates use JSON for declarative infrastructure definition.
    
* Parameters can be stored in separate JSON files.
    
* ARM templates can be deployed via various methods.
    
* Bicep offers a simpler and more efficient alternative to ARM templates.
