Provision Virtual Machines

Objective : Provision Virtual Machines

Solution

Create a virtual machine using Azure Portal, Azure CLI and Azure PowerShell

Step 1: Start the lab, agree after reading terms and conditions and check the credential/URL provided on the page.

Step 2: Open the Login URL link in incognito (Right click on the URL and select Open link in incognito Window option).

The URL will take you to the Azure Portal login page. Use the provided username and password to login into it.

Enter password

Step 3: An empty resource group will be visible. Click on Create option to create aVirtual Network, Storage Account and virtual machine

Step 4: Create a Virtual Machine as shown below

Select Size as shown below

Enter the administrative details and Click on Review and Create

After successful Validation Click Create

Navigate to your Resource for more details. Click on Connect option, select Bastion

Step 5: Select Create Azure Bastion using Defaults. It uses default Subnet to create Bastion and connect to the Virtual Machine. It may take a few minutes

Enter username and Password and Click Connect

Once connected, Open powershell and enter the command given below to verify Azure agent Related Windows Services

Get-Service | ? {$_.Name -like "*Azure*"} | Select Name

Step 6: Deploy a Virtual Machine using Azure CLI. Install Azure CLI using the Appendix A below

Step 7: Login to your account using azure command

az login

az vm create -n <virtual-machine-name> -g <resource-group-name> --image Canonical:UbuntuServer:18.04-LTS:latest -l <location> --authentication-type password --admin-username <administrator-username> --admin-password <password> --vnet-name <virtual-network-name> --subnet <subnet-name> --public-ip-address <public-ip-name>  --public-ip-sku Standard --size Standard_B1s

Note Use Virtual network and Subnet Created in Step 4

Navigate to Azure Portal and verify your Virtual Machine. Click on Connect. Select Bastion

Enter Aministrative Credentials and Click Connect

Once you access your Virtual Machine, verify the running to azure related linux daemon using the following command

ps -aux | grep waagent

Step 8: Delete the Resources. Navigate to your Virtual Machine, Click on Delete option in

Navigate to Public ip. Click on Delete option

Naviagte to Network Security Group. Click on Delete option

Step 9: Deploy Virtual Machine using Azure Powershell or Azure Bash Terminal

Provide the Credentials for Administrative account using the azure command

$cred =  Get-Credential

Connect to your Account using the azure command

Connect-AzAccount

Create a Virtual Machine using the following command

New-AzVm -ResourceGroupName <resource-group-name> -Location <location-name> -Credential $cred -Image Win2016Datacenter -Name <virtual-machine-name> -VirtualNetworkName <virtual-Network-Name> -SubnetName <default> -PublicIpAddressName <public-ip-name> -OpenPorts 3389 -Size Standard_B1s

Note Use Virtual network and Subnet Created in Step 4

Step 10: Naviagte to Azure Portal. Delete the resources using Delete option (Shown in Step 8)

Conclusion

In this way you can Create a virtual machine,storage account and virtual network, configure storage endpoints for Storage Account in the Virtual Network. Verfiy using the virtual Machine

Appendix A : Install Azure CLI

1.For Windows, the Azure CLI is installed via a MSI, which gives you access to the CLI through the Windows Command Prompt (CMD) or PowerShell.

2. Download the latest release of Azure CLI from https://aka.ms/installazurecliwindows. An MSI file will be downloaded as shown below

3. Open the msi file and It will prepare to install cli on your local machine. Accept the terms and conditions. Click on install

4.When the installer asks if it can make changes to your computer, click the "Yes" box. After the installation is complete, you will need to close and reopen any active Windows Command Prompt or PowerShell windows to use the Azure CLI.

5. For the macOS platform, you can install the Azure CLI with Homebrew package Managers which used to manage your CLI installation.

6.Download homebrew from https://docs.brew.sh/Installation.html

7.Install brew by using following command in bash

brew update && brew install azure-cli
8.For Ubuntu/Debian platform, Installation can be done with one command given below.

This script is downloaded via curl and piped directly to bash to install the CLI.
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
9. You can check if the installation is successful with any azure command.