Exercise 7. Exporting a Template from Azure Portal
Goal: See your week‑one Ubuntu VM and its network as Infrastructure as Code by exporting the deployment to an ARM template. This will give you a concrete reference before we author templates ourselves.
Estimated time: 15–25 minutes
Learning outcomes
- Understand how Azure resources are represented in ARM.
- Identify parameters, variables, resources, and dependsOn.
- Map resource types to our diagram: VNet/Subnet, NSG, Public IP, NIC, Ubuntu VM.
Prerequisites
- You already created the VM in the Azure Portal (from Exercise 1/2/3/5/6).
- Access to the Resource Group that holds the VM and its networking.
What you’ll produce
- A downloaded ZIP containing
template.jsonandparameters.json(generated by the portal). - A short note with the resource types you found and how they relate.
Steps
Open your Resource Group
- Azure Portal → Resource groups → select the RG that contains your VM, VNet, NSG, Public IP, NIC.
Export the template
- In the RG, look for Export template (sometimes under Settings or Automation).
- Click Export template → Download (ZIP).
Unpack & open in VS Code
- Unzip locally. Open the folder in VS Code.
- Files you should see:
template.json,parameters.json, and a README snippet. - (Optional) Install Azure Resource Manager (ARM) Tools extension for JSON schema help.
Read the template (guided tour)
- parameters → values the template expects (e.g., location, admin username).
- variables → name building or convenience values.
- resources → look for these types and write them down:
Microsoft.Network/virtualNetworksMicrosoft.Network/networkSecurityGroupsMicrosoft.Network/publicIPAddressesMicrosoft.Network/networkInterfacesMicrosoft.Compute/virtualMachines
- dependsOn → note how NIC depends on Public IP/NSG/VNet, and how VM depends on NIC.
- outputs → check if any are present (often none in exports).
Map to the diagram (quick check)
- Internet → Public IP → NIC/NSG → VM (Nginx via cloud‑init).
- Confirm each hop exists in
resourcesand note the names.
Notes on exports (know the limits)
- Exports are best‑effort and may not reflect all features or your naming conventions.
- Parameterization is basic; we’ll improve this with Bicep in the next exercise.
Verification
Create a short note (5–8 bullets) answering:
- Which resource types did you find?
- What does the VM depend on?
- Which NSG rules exist for SSH (22) and HTTP (80)?
- Where is the location set (parameter or literal)?
- Anything surprising or unclear in the export?
Stretch (optional)
- If you have Bicep installed, try:Open the generated
az bicep decompile --file template.jsontemplate.bicepand compare readability.
Cleanup
None. Keep the exported template for reference; we’ll author a minimal template next.