Chapter 22 Implementing Virtual Networks with CLI & PS

This Chapter covers following Lab Exercises

  • Create Resource Group HKCLI using Azure CLI
  • Create Resource Group HKPS using Azure PowerShell
  • Create Virtual Network VNETCLI using Azure CLI
  • Create Virtual Network VNETPS using Azure PowerShell

Exercise 181: Create Resource Group HKCLI using Azure CLI

You can either use Azure CLI on your desktop or use Cloud shell. For this lab use Azure CLI installed on our desktop. See Chapter 18 on how to use Azure CLI.

  1. Open windows CMD on your desktop where Azure CLI is installed>Enter Command az login > This will open a browser. Select Account and Enter subscription credentials.

    Screenshot_744
  2. After you have successfully authenticated to Azure through Browser, The CMD window will now show Azure login information as shown below.

    Screenshot_745

    Create Resource Group using az group command az group create --name HKCLI --location eastus2

    Screenshot_746

    Check the Resource Group created
    az group show --name HKCLI or
    az group show --resource-group HKCLI

    Screenshot_747

    Deleting Resource Group
    az group delete --name HKCLI --yes
    Note: Don’t run above command as we need to create resources in the group.

Exercise 182: Create Resource Group HKPS using Azure PowerShell

Note : you can either install and use Azure PowerShell Module on your desktop or use Cloud shell. Refer to chapter 18 for Installing and using Azure PowerShell.

Open PowerShell on your desktop and login using ConnectAzureRmAccount.

Screenshot_748

Create Resource Group
New-AzureRmResourceGroup -Name HKPS -Location eastus2

Screenshot_749

Check the Resource Group HKPS created
Get-AzureRMResourceGroup
Get-AzureRmResourceGroup -Name HKPS

Screenshot_750

Deleting Resource Group
Remove-AzureRmResourceGroup -Name HKPS -Force
Note: Don’t run above command as we need to create resources in the group.

Exercise 183: Create Virtual Network VNETCLI using Azure CLI

In this exercise we will create Virtual Network “VNETCLI” in Resource Group HKCLI using 10.2.0.0/16 address space in East US 2 Location. We will also create Subnet with name Web-Subnet with address 10.2.1.0/24.

Open cmd and enter az login command for Authenticating to Subscription.

Create Virtual Network using az network vnet command
az network vnet create --name VNETCLI --address-prefix 10.2.0.0/16 -- resource-group HKCLI --subnet-name Web-Subnet --address-prefix 10.2.1.0/24

Screenshot_751

Check the Virtual Network created
az network vnet show --name VNETCLI --resource-group HKCLI

Screenshot_752

Delete Virtual Network
az network vnet delete --name VNETCLI --resource-group HKCLI Note: Don’t run above command as we need to create resources in the VNET.

Exercise 184: Create Virtual Network VNETPS using Azure PowerShell

In this exercise we will create Virtual Network “VNETPS” in Resource Group HKPS using 10.3.0.0/16 address space in East US 2 Location. We will also create Subnet with name Web-Subnet with address 10.3.1.0/24.

Open PowerShell on your desktop and login using ConnectAzureRmAccount.

Create Subnet name Web-Subnet
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name Web-Subnet -AddressPrefix 10.3.1.0/24

Screenshot_753

Create Virtual Network
New-AzureRmVirtualNetwork -Name VNETPS -ResourceGroupName HKPS -Location eastus2 -AddressPrefix 10.3.0.0/16 -Subnet $subnet

Screenshot_754

Check the Virtual Network created
Get-AzureRmVirtualNetwork -Name VNETPS -ResourceGroupName HKPS

Delete Virtual Network
Remove-AzureRmVirtualNetwork -Name VNETPS -ResourceGroupName HKPS
Note : Don’t run above command as we need to create resources in the VNET.

UP

LIMITED OFFER: GET 30% Discount

This is ONE TIME OFFER

ExamSnap Discount Offer
Enter Your Email Address to Receive Your 30% Discount Code

A confirmation link will be sent to this email address to verify your login. *We value your privacy. We will not rent or sell your email address.

Download Free Demo of VCE Exam Simulator

Experience Avanset VCE Exam Simulator for yourself.

Simply submit your e-mail address below to get started with our interactive software demo of your free trial.

Free Demo Limits: In the demo version you will be able to access only first 5 questions from exam.