| title | include file |
|---|---|
| description | include file |
| services | networking |
| author | mbender-ms |
| ms.service | networking |
| ms.topic | include |
| ms.date | 03/21/2025 |
| ms.author | mbender |
| ms.custom | include file |
To achieve the scenario outlined in this article complete the following steps:
-
Install and Configure the Azure CLI by following the steps in the linked article and log into your Azure account.
-
Create a resource group called contosofabrikam as follows:
az group create contosofabrikam westcentralus -
Create an availability set to for the two VMs. For this scenario, use the following command:
az vm availability-set create --resource-group contosofabrikam --location westcentralus --name myAvailabilitySet -
Create a virtual network called myVNet and a subnet called mySubnet:
az network vnet create --resource-group contosofabrikam --name myVnet --address-prefixes 10.0.0.0/16 --location westcentralus --subnet-name MySubnet --subnet-prefix 10.0.0.0/24 -
Create the load balancer called mylb:
az network lb create --resource-group contosofabrikam --location westcentralus --name mylb -
Create two dynamic public IP addresses for the frontend IP configurations of your load balancer:
az network public-ip create --resource-group contosofabrikam --location westcentralus --name PublicIp1 --domain-name-label contoso --allocation-method Dynamic az network public-ip create --resource-group contosofabrikam --location westcentralus --name PublicIp2 --domain-name-label fabrikam --allocation-method Dynamic -
Create the two frontend IP configurations, contosofe and fabrikamfe respectively:
az network lb frontend-ip create --resource-group contosofabrikam --lb-name mylb --public-ip-name PublicIp1 --name contosofe az network lb frontend-ip create --resource-group contosofabrikam --lb-name mylb --public-ip-name PublicIp2 --name fabrikamfe -
Create your backend address pools - contosopool and fabrikampool, a probe - HTTP, and your load balancing rules - HTTPruleContoso and HTTPruleFabrikam:
az network lb address-pool create --resource-group contosofabrikam --lb-name mylb --name contosopool azure network lb address-pool create --resource-group contosofabrikam --lb-name mylb --name fabrikampool az network lb probe create --resource-group contosofabrikam --lb-name mylb --name HTTP --protocol "http" --interval 15 --count 2 --path index.html az network lb rule create --resource-group contosofabrikam --lb-name mylb --name HTTPruleContoso --protocol tcp --probe-name http--frontend-port 5000 --backend-port 5000 --frontend-ip-name contosofe --backend-address-pool-name contosopool az network lb rule create --resource-group contosofabrikam --lb-name mylb --name HTTPruleFabrikam --protocol tcp --probe-name http --frontend-port 5000 --backend-port 5000 --frontend-ip-name fabrikamfe --backend-address-pool-name fabrikampool -
Check the output to verify your load balancer was created correctly by running the following command:
az network lb show --resource-group contosofabrikam --name mylb -
Create a public IP, myPublicIp, and storage account, mystorageaccont1 for your first virtual machine VM1 as follows:
az network public-ip create --resource-group contosofabrikam --location westcentralus --name myPublicIP --domain-name-label mypublicdns345 --allocation-method Dynamic az storage account create --location westcentralus --resource-group contosofabrikam --kind Storage --sku-name GRS mystorageaccount1 -
Create the network interfaces for VM1 and add a second IP configuration, VM1-ipconfig2, and create the VM as follows:
az network nic create --resource-group contosofabrikam --location westcentralus --subnet-vnet-name myVnet --subnet-name mySubnet --name VM1Nic1 --ip-config-name NIC1-ipconfig1 az network nic create --resource-group contosofabrikam --location westcentralus --subnet-vnet-name myVnet --subnet-name mySubnet --name VM1Nic2 --ip-config-name VM1-ipconfig1 --public-ip-name myPublicIP --lb-address-pool-ids "/subscriptions/<your subscription ID>/resourceGroups/contosofabrikam/providers/Microsoft.Network/loadBalancers/mylb/backendAddressPools/contosopool" az network nic ip-config create --resource-group contosofabrikam --nic-name VM1Nic2 --name VM1-ipconfig2 --lb-address-pool-ids "/subscriptions/<your subscription ID>/resourceGroups/contosofabrikam/providers/Microsoft.Network/loadBalancers/mylb/backendAddressPools/fabrikampool" az vm create --resource-group contosofabrikam --name VM1 --location westcentralus --os-type linux --nic-names VM1Nic1,VM1Nic2 --vnet-name VNet1 --vnet-subnet-name Subnet1 --availability-set myAvailabilitySet --vm-size Standard_DS3_v2 --storage-account-name mystorageaccount1 --image-urn canonical:UbuntuServer:16.04.0-LTS:latest --admin-username <your username> --admin-password <your password> -
Repeat steps 10-11 for your second VM:
az network public-ip create --resource-group contosofabrikam --location westcentralus --name myPublicIP2 --domain-name-label mypublicdns785 --allocation-method Dynamic az storage account create --location westcentralus --resource-group contosofabrikam --kind Storage --sku-name GRS mystorageaccount2 az network nic create --resource-group contosofabrikam --location westcentralus --subnet-vnet-name myVnet --subnet-name mySubnet --name VM2Nic1 az network nic create --resource-group contosofabrikam --location westcentralus --subnet-vnet-name myVnet --subnet-name mySubnet --name VM2Nic2 --ip-config-name VM2-ipconfig1 --public-ip-name myPublicIP2 --lb-address-pool-ids "/subscriptions/<your subscription ID>/resourceGroups/contosofabrikam/providers/Microsoft.Network/loadBalancers/mylb/backendAddressPools/contosopool" az network nic ip-config create --resource-group contosofabrikam --nic-name VM2Nic2 --name VM2-ipconfig2 --lb-address-pool-ids "/subscriptions/<your subscription ID>/resourceGroups/contosofabrikam/providers/Microsoft.Network/loadBalancers/mylb/backendAddressPools/fabrikampool" az vm create --resource-group contosofabrikam --name VM2 --location westcentralus --os-type linux --nic-names VM2Nic1,VM2Nic2 --vnet-name VNet1 --vnet-subnet-name Subnet1 --availability-set myAvailabilitySet --vm-size Standard_DS3_v2 --storage-account-name mystorageaccount2 --image-urn canonical:UbuntuServer:16.04.0-LTS:latest --admin-username <your username> --admin-password <your password> -
Finally, you must configure DNS resource records to point to the respective frontend IP address of the Load Balancer. You can host your domains in Azure DNS. For more information about using Azure DNS with Load Balancer, see Using Azure DNS with other Azure services