Demo overview
During this demo, we will create an Azure Resource Group and deploy a virtual machine using Infrastructure as Code (IaC).
The environment will look like this:
Pre-requisites
Some pre-requisites are needed to follow the training.
This guide will help you to install the needed software and create a directory structure for the training.
Please note the time, we have a maximum of 90 minutes for this training.
Azure CLI
Below scripts are Windows based, running MAC or Linux?
Please check the Azure CLI page and install the CLI for your operating system.
MAC or Linux users please note to use the Powershell shell and not the default shell.
-
Open a Powershell terminal window in administrator mode
- Right-click on the Windows icon in your task bar and choose Terminal (admin), PowerShell (admin) (depending on your operating system version/settings)
-
Run the following command to install the Azure CLI (don't forget to press enter)
$dc = New-Object NET.WebClient; $dc.UseDefaultCredentials = $true; $dc.Headers.Add("user-agent", "Internet Explorer"); $dc.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f"); $dc.DownloadFile('https://aka.ms/installazurecliwindowsx64', '.\AzureCLI.msi'); Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /passive'; Remove-Item .\AzureCLI.msi;
-
Close the terminal window when the installation is finished
Azure CLI information can be found here.
If you already have the Azure CLI installed, please make sure it is up to date by running the following command:
az upgrade
In the next steps we'll be using .bicepparam to deploy the resources and this is only available in the latest version of the Azure CLI.
The error will look something like this:
Failed to parse 'C:\DTX-IaC-Demo\resourcegroup-002.bicepparam', please check whether it is a valid JSON format
Failed to parse 'C:\DTX-IaC-Demo\resourcegroup-003.bicepparam', please check whether it is a valid JSON format
Failed to parse 'C:\DTX-IaC-Demo\resourcegroup.bicepparam', please check whether it is a valid JSON format
Visual Studio Code
Install Visual Studio Code from the official site.
-
Choose Download for "Operation System" (Choose your operation system)
-
Wait for the download to complete
-
Run the installer by clicking on the downloaded file
-
Follow the installation wizard, all settings can be left as default
- Optional set the following 2 boxes if you prefer this
- Optional set the following 2 boxes if you prefer this
-
Click Finish to complete the installation, this will launch Visual Studio Code (you can close this instance)
-
Open a new Powershell terminal window
-
Right-click on the Windows icon in your task bar and choose Terminal, PowerShell (depending on your operating system version/settings)
code --install-extension ms-azuretools.vscode-bicep
This will install the Bicep extension for Visual Studio Code
-
Directory structure
Create a directory structure for the training.
-
Open a Powershell terminal window
- Right-click on the Windows icon in your task bar and choose Terminal, PowerShell (depending on your operating system version/settings)
mkdir C:\DTX-IaC-Demo; code C:\DTX-IaC-Demo\;
This will open Visual Studio Code in the directory
C:\DTX-IaC-Demo
-
Trust the folder when asked
-
You can close the welcome tab
-
Select View > Terminal from the menu to open a terminal window in Visual Studio Code
All powershell commands will be run within the Terminal of Visual Studio Code.
If the az commands aren't recognized, please close all the Visual Studio Code instances and open a new one.
-
Login to Azure CLI from the opened terminal window with:
This will open a web page to login to Azure, use your credentials provided by DTX to login, you can close the browser window when you see the message
You have logged into Microsoft Azure!
If prompted to select a subscription, please select the subscription provided by DTX.
The stay signed in message can be ignored by pressing No, sign in to this app only
.
Version overview
This document has the following versions:
Version | Date | Overview of changes |
---|---|---|
1.1 | 2024-03-26 | Added comments from DTX25. |
1.0 | 2024-02-28 | Initial version. |