This lab will walk you through creating a Linux based Virtual Machine on the Azure Portal.
Note: This lab is part of a series of labs for Mastering the Virtual Machine Offers Workshop. You should finish this lab as well as prior ones before moving on to the next sections.
- Clone the repository to access files in scripts folder
- Navigate to the Homepage of Azure Portal
- Use the Search bar to search for Storage Accounts and hit enter. Select the vmworkshopsayouruniquestring Storage account we created in the previous lab.
- In the left pane, look for Data Storage and select Containers
- Click on + Container to create a new container
- Enter script as the new container name
- Select Blob for Public access level
- Click Create at the bottom of the page
- Open the new container, select Upload and upload the cloned script named custom_extension_linux.sh
- If you open this script in VS Code or Notepad, you will see that it is running commands to install a web server and update the Virtual machine
- Navigate to the Homepage of Azure Portal
- Click on the + Create a resource button underneath Azure services
- Use the Search bar to search for Virtual Machine and hit enter. Select the Virtual Machine offered by Microsoft Azure Service and click on Create
At this point you will be taken to the Virtual Machine service with several blades for configuration.
-
Select the Subscription from the dropdown menu to select which subscription will pay for the VM and other resource usage
-
To create a new Resource Group, click on Create New and name your resource group as vmworkshop-rg-YOUR_UNIQUE_STRING. Please make sure to follow the same convention for ease of access and understanding.
Note that all the resources we create for the labs will reside within this new resource group
- Name your Virtual Machine vmworkshop-YOUR_UNIQUE_STRING
- Select the Region you are in from the dropdown menu
- Under Availability options, select No infrastructure redundancy required
- Select Standard Security type
- For Image, click on See all images and select Ubuntu Server 20.04 LTS - Gen2. Configure the generation from the Configure VM Generation link below if necessary.
- For size, click on See all sizes and select Standard_B2ms. This is sufficient to run this lab and will cost around $60/month, but regardless we will stop this virtual machine as soon as we generalize and capture the VM, so usage should be very low.
- Select SSH public key as authentication type
- Enter the username of your choice
- Select Generate a new key pair from the dropdown for SSH public key source
- Eneter the name of your Key pair
- Select the Allow selected ports radio button for Public inbound ports
- For Select Inbound ports Select HTTP as well as SSH
- Leave the rest as is and Click Next : Disks >
- For OS Disk Type, select Standard HDD (locally-redundant storage)
Leave the rest of the fields as is on the page and click on Next : Networking >
- For Virtual network, Subnet, Public IP keep the default values as is. This will create a new VM, Subnet and Public IP with the default variable names
- Ensure Select inbound ports has HTTP and SSH checked
Leave the rest as is and click on Next : Management >
Do not change anything in this section and simply click on Next : Advanced >
We may use the Advanced blade to customize the VM in two ways. Firstly using Custom Script Extensions and secondly using cloud init. In this module we will demonstrate both, but you should choose to do only once since both paths will essentially do the same flow of changes.
- Navigate to the custom data and cloud init section
- Copy the code from the custom_extension_linux.sh script in this repository and paste it as is
(or)
- Click on Select an extension to install
- From the display card, select Custom Script For Linux and click on Next
- For Script file, browse for the vmworkshopsayouruniquestring storage account, select script and look for the custom_extension_linux.sh Block blob and select it. [If you dont see storage account, please make sure it is in the same region as the VM which is being created]
- Under command, modify it to sh custom_extension_linux.sh
Select Review + create button at the bottom of the Advanced blade
- In this blade, you should ensure that you receive the Validation Passed message at the top. If for any reason you receive a Validation failed message, you should go back and review the fields in red.
- Lastly take a look at the configurations you have selected and click Create
- A popup will show on the screen to indicate creation of a new Key pair
- Select Download private key and create resource and save it
- At this point your deployment will start and show an in progress status.
- Once the deployment is complete, select Go to resource
- Copy Public IP Address from the created VM and paste it into a browser of your choice. This will show a public facing IP on the internet with a custom Welcome screen.
- Once you see the custom welcome screen, you know that the post deployment script has done its job.
Congratulations! You have now finished this lab.
If you are in a live class setting, please raise your hand (even if virtually) to indicate you are done with the lab.