Create Pull Request
| Date | Scan | Status | Result |
|---|---|---|---|
| 2025-08-17 00:01 | #83 | cancelled |
Clean
|
| 2025-07-13 21:37 | #48 | completed |
Biased
|
| 2025-07-12 23:44 | #41 | cancelled |
Biased
|
## Configure virtual network When you create an internal load balancer, a virtual network is configured as the network for the load balancer. Before you deploy VMs and test your load balancer, create the supporting virtual network resources. Create a virtual network for the backend virtual machines Create a network security group to define inbound connections to your virtual network Create an Azure Bastion host to securely manage the virtual machines in the backend pool ### Create virtual network, network security group and bastion host * Create a virtual network with [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork) * Create a network security group rule with [New-AzNetworkSecurityRuleConfig](/powershell/module/az.network/new-aznetworksecurityruleconfig) * Create an Azure Bastion host with [New-AzBastion](/powershell/module/az.network/new-azbastion) > [!IMPORTANT] > [!INCLUDE [Pricing](~/reusable-content/ce-skilling/azure/includes/bastion-pricing.md)] >
## Create virtual machines
In this section, you'll create the two virtual machines for the backend pool of the load balancer.
* Create three network interfaces with [New-AzNetworkInterface](/powershell/module/az.network/new-aznetworkinterface)
* Set an administrator username and password for the VMs with [Get-Credential](/powershell/module/microsoft.powershell.security/get-credential)
* Use [New-AzAvailabilitySet](/powershell/module/az.compute/new-azvm) to create an availability set for the virtual machines.
* Create the virtual machines with:
* [New-AzVM](/powershell/module/az.compute/new-azvm)
* [New-AzVMConfig](/powershell/module/az.compute/new-azvmconfig)
* [Set-AzVMOperatingSystem](/powershell/module/az.compute/set-azvmoperatingsystem)
* [Set-AzVMSourceImage](/powershell/module/az.compute/set-azvmsourceimage)
* [Add-AzVMNetworkInterface](/powershell/module/az.compute/add-azvmnetworkinterface)
The deployments of the virtual machines and bastion host are submitted as PowerShell jobs. To view the status of the jobs, use [Get-Job](/powershell/module/microsoft.powershell.core/get-job):
## Create load balancer This section details how you can create and configure the following components of the load balancer: * Create a frontend IP with [New-AzLoadBalancerFrontendIpConfig](/powershell/module/az.network/new-azloadbalancerfrontendipconfig) for the frontend IP pool. This IP receives the incoming traffic on the load balancer * Create a backend address pool with [New-AzLoadBalancerBackendAddressPoolConfig](/powershell/module/az.network/new-azloadbalancerbackendaddresspoolconfig) for traffic sent from the frontend of the load balancer * Create a health probe with [Add-AzLoadBalancerProbeConfig](/powershell/module/az.network/add-azloadbalancerprobeconfig) that determines the health of the backend VM instances * Create a load balancer rule with [Add-AzLoadBalancerRuleConfig](/powershell/module/az.network/add-azloadbalancerruleconfig) that defines how traffic is distributed to the VMs * Create a public load balancer with [New-AzLoadBalancer](/powershell/module/az.network/new-azloadbalancer)
[!INCLUDE [ephemeral-ip-note.md](~/reusable-content/ce-skilling/azure/includes/ephemeral-ip-note.md)] ## Create the test virtual machine Create the virtual machine with: * [New-AzNetworkInterface](/powershell/module/az.network/new-aznetworkinterface) * [New-AzVM](/powershell/module/az.compute/new-azvm) * [New-AzVMConfig](/powershell/module/az.compute/new-azvmconfig) * [Set-AzVMOperatingSystem](/powershell/module/az.compute/set-azvmoperatingsystem) * [Set-AzVMSourceImage](/powershell/module/az.compute/set-azvmsourceimage) * [Add-AzVMNetworkInterface](/powershell/module/az.compute/add-azvmnetworkinterface)
## Install IIS Use [Set-AzVMExtension](/powershell/module/az.compute/set-azvmextension) to install the Custom Script Extension. The extension runs `PowerShell Add-WindowsFeature Web-Server` to install the IIS webserver and then updates the Default.htm page to show the hostname of the VM: > [!IMPORTANT] > Ensure the virtual machine deployments have completed from the previous steps before proceeding. Use `Get-Job` to check the status of the virtual machine deployment jobs.
The extensions are deployed as PowerShell jobs. To view the status of the installation jobs, use [Get-Job](/powershell/module/microsoft.powershell.core/get-job):
> [!IMPORTANT] > Ensure the custom script extension deployments have completed from the previous steps before proceeding. Use `Get-Job` to check the status of the deployment jobs. ## Test the load balancer 1. [Sign in](https://portal.azure.com) to the Azure portal. 1. Find the private IP address for the load balancer on the **Overview** screen. Select **All services** in the left-hand menu, select **All resources**, and then select **myLoadBalancer**. 2. Make note or copy the address next to **Private IP Address** in the **Overview** of **myLoadBalancer**. 3. Select **All services** in the left-hand menu, select **All resources**, and then from the resources list, select **myTestVM** that is located in the **CreateIntLBQS-rg** resource group. 4. On the **Overview** page, select **Connect**, then **Bastion**. 6. Enter the username and password entered during VM creation. 7. Open **Internet Explorer** on **myTestVM**. 8. Enter the IP address from the previous step into the address bar of the browser. The default page of IIS Web server is displayed on the browser. To see the load balancer distribute traffic across all three VMs, you can customize the default page of each VM's IIS Web server and then force-refresh your web browser from the client machine. ## Clean up resources When no longer needed, you can use the [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup) command to remove the resource group, load balancer, and the remaining resources.