title | description | services | documentationcenter | author | manager | editor | tags | ms.assetid | ms.service | ms.devlang | ms.topic | ms.tgt_pltfrm | ms.workload | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PowerShell Example - Load balance multiple websites with Azure PowerShell | Microsoft Docs |
This Azure PowerShell script example hows how to load balance multiple websites to the same virtual machine |
load-balancer |
load-balancer |
KumudD |
jeconnoc |
tysonn |
load-balancer |
powershell |
sample |
infrastructure |
04/20/2018 |
kumud |
This Azure PowerShell script example creates a virtual network with two virtual machines (VM) that are members of an availability set. A load balancer directs traffic for two separate IP addresses to the two VMs. After running the script, you could deploy web server software to the VMs and host multiple web sites, each with its own IP address.
If needed, install the Azure PowerShell using the instruction found in the Azure PowerShell guide, and then run Login-AzureRmAccount
to create a connection with Azure.
[!INCLUDE quickstarts-free-trial-note]
[!code-powershellmain]
Run the following command to remove the resource group, VM, and all related resources.
Remove-AzureRmResourceGroup -Name myResourceGroup
This script uses the following commands to create a resource group, virtual network, load balancer, and all related resources. Each command in the table links to command specific documentation.
Command | Notes |
---|---|
New-AzureRmResourceGroup | Creates a resource group in which all resources are stored. |
New-AzureRmAvailabilitySet | Creates an Azure availability set to provide high availability. |
New-AzureRmVirtualNetworkSubnetConfig | Creates a subnet configuration. This configuration is used with the virtual network creation process. |
New-AzureRmVirtualNetwork | Creates a virtual network. |
New-AzureRmPublicIpAddress | Creates a public IP address. |
New-AzureRmLoadBalancerFrontendIpConfig | Creates a front end IP config for a load balancer. |
New-AzureRmLoadBalancerBackendAddressPoolConfig | Creates a backend address pool configuration for a load balancer. |
New-AzureRmLoadBalancerProbeConfig | Creates an NLB probe. An NLB probe is used to monitor each VM in the NLB set. If any VM becomes inaccessible, traffic is not routed to the VM. |
New-AzureRmLoadBalancerRuleConfig | Creates an NLB rule. In this sample, a rule is created for port 80. As HTTP traffic arrives at the NLB, it is routed to port 80 one of the VMs in the NLB set. |
New-AzureRmLoadBalancer | Creates a load balancer. |
New-AzureRmNetworkInterfaceIpConfig | Defines advanced features for a virtual network interface. |
New-AzureRmNetworkInterface | Creates a network interface. |
New-AzureRmVMConfig | Creates a VM configuration. This configuration includes information such as VM name, operating system, and administrative credentials. The configuration is used during VM creation. |
New-AzureRmVM | Create a virtual machine. |
Remove-AzureRmResourceGroup | Removes a resource group and all resources contained within. |
For more information on the Azure PowerShell, see Azure PowerShell documentation.
Additional networking PowerShell script samples can be found in the Azure Networking Overview documentation.