Skip to content

Commit 510fc64

Browse files
authored
Merge pull request #190645 from carlrab/azurecli_load_balancer
Freshen parent files
2 parents e44938e + 94bda24 commit 510fc64

5 files changed

+63
-277
lines changed

articles/load-balancer/TOC.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@
6666
- name: Samples
6767
items:
6868
- name: Azure CLI
69-
href: cli-samples.md
69+
items:
70+
- name: Overview
71+
href: cli-samples.md
72+
- name: Load balance traffic to VMs for high availability
73+
href: ./scripts/load-balancer-linux-cli-sample-nlb.md
74+
- name: Load balance VMs across availability zones
75+
href: ./scripts/load-balancer-linux-cli-sample-zone-redundant-frontend.md
76+
- name: Load balance VMs within a specific availability zone
77+
href: ./scripts/load-balancer-linux-cli-sample-zonal-frontend.md
78+
- name: Load balance multiple websites on VMs
79+
href: ./scripts/load-balancer-linux-cli-load-balance-multiple-websites-vm.md
7080
- name: Azure PowerShell
7181
href: powershell-samples.md
7282
- name: Python

articles/load-balancer/scripts/load-balancer-linux-cli-load-balance-multiple-websites-vm.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: load-balancer
77
ms.devlang: azurecli
88
ms.topic: sample
99
ms.workload: infrastructure
10-
ms.date: 04/20/2018
10+
ms.date: 03/04/2022
1111
ms.author: allensu
1212
ms.custom: devx-track-azurecli
1313
---
@@ -16,24 +16,27 @@ ms.custom: devx-track-azurecli
1616

1717
This Azure CLI script sample 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.
1818

19-
[!INCLUDE [sample-cli-install](../../../includes/sample-cli-install.md)]
20-
2119
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
2220

21+
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
22+
2323
## Sample script
2424

25+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
26+
27+
### Run the script
2528

26-
[!code-azurecli-interactive[main](../../../cli_scripts/load-balancer/load-balance-multiple-web-sites-vm/load-balance-multiple-web-sites-vm.sh "Load balance multiple web sites")]
29+
:::code language="azurecli" source="~/azure_cli_scripts/load-balancer/load-balance-multiple-web-sites-vm/load-balance-multiple-web-sites-vm.sh" id="FullScript":::
2730

28-
## Clean up deployment
31+
## Clean up resources
2932

30-
Run the following command to remove the resource group, VM, and all related resources.
33+
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
3134

3235
```azurecli
33-
az group delete --name myResourceGroup --yes
36+
az group delete --name $resourceGroup
3437
```
3538

36-
## Script explanation
39+
## Sample reference
3740

3841
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.
3942

@@ -57,4 +60,4 @@ This script uses the following commands to create a resource group, virtual netw
5760

5861
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
5962

60-
Additional networking CLI script samples can be found in the [Azure Networking Overview documentation](../cli-samples.md?toc=%2fazure%2fnetworking%2ftoc.json).
63+
Additional networking CLI script samples can be found in the [Azure Networking Overview documentation](../cli-samples.md?toc=%2fazure%2fnetworking%2ftoc.json).

articles/load-balancer/scripts/load-balancer-linux-cli-sample-nlb.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,36 @@ ms.service: load-balancer
99
ms.devlang: azurecli
1010
ms.topic: sample
1111
ms.workload: infrastructure
12-
ms.date: 04/20/2018
12+
ms.date: 03/04/2022
1313
ms.author: allensu
1414
ms.custom: devx-track-azurecli
1515
---
1616

1717
# Azure CLI script example: Load balance traffic to VMs for high availability
1818

19-
This Azure CLI script example creates everything needed to run several Ubuntu virtual machines configured in a highly available and load balanced configuration. After running the script, you will have three virtual machines, joined to an Azure Availability Set, and accessible through an Azure Load Balancer.
20-
21-
[!INCLUDE [sample-cli-install](../../../includes/sample-cli-install.md)]
19+
This Azure CLI script example creates everything needed to run several Ubuntu virtual machines configured in a highly available and load balanced configuration. After running the script, you will have three virtual machines, joined to an Azure Availability Set, and accessible through an Azure Load Balancer.
2220

2321
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
2422

23+
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
24+
2525
## Sample script
2626

27-
## Clean up deployment
27+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
28+
29+
### Run the script
30+
31+
:::code language="azurecli" source="~/azure_cli_scripts/load-balancer/create-vm-nlb/create-vm-nlb.sh" id="FullScript":::
32+
33+
## Clean up resources
2834

29-
Run the following command to remove the resource group, VM, and all related resources.
35+
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
3036

3137
```azurecli
32-
az group delete --name myResourceGroup
38+
az group delete --name $resourceGroup
3339
```
3440

35-
## Script explanation
41+
## Sample reference
3642

3743
This script uses the following commands to create a resource group, virtual machine, availability set, load balancer, and all related resources. Each command in the table links to command specific documentation.
3844

@@ -56,4 +62,4 @@ This script uses the following commands to create a resource group, virtual mach
5662

5763
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
5864

59-
Additional Azure Networking CLI script samples can be found in the [Azure Networking documentation](../cli-samples.md).
65+
Additional Azure Networking CLI script samples can be found in the [Azure Networking documentation](../cli-samples.md).

articles/load-balancer/scripts/load-balancer-linux-cli-sample-zonal-frontend.md

Lines changed: 13 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -12,153 +12,36 @@ ms.devlang: azurecli
1212
ms.topic: sample
1313
ms.tgt_pltfrm:
1414
ms.workload: infrastructure
15-
ms.date: 06/14/2018
15+
ms.date: 03/04/2022
1616
ms.author: allensu
1717
ms.custom: devx-track-azurecli
1818
---
1919

2020
# Azure CLI script example: Load balance traffic to VMs within a specific availability zone
2121

22-
This Azure CLI script example creates everything needed to run several Ubuntu virtual machines configured in a highly available and load balanced configuration within a specific availability zone. After running the script, you will have three virtual machines in a single availability zones within a region that are accessible through an Azure Standard Load Balancer.
23-
24-
[!INCLUDE [sample-cli-install](../../../includes/sample-cli-install.md)]
22+
This Azure CLI script example creates everything needed to run several Ubuntu virtual machines configured in a highly available and load balanced configuration within a specific availability zone. After running the script, you will have three virtual machines in a single availability zones within a region that are accessible through an Azure Standard Load Balancer.
2523

2624
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
2725

26+
[!INCLUDE [azure-cli-prepare-your-environment.md](../../../includes/azure-cli-prepare-your-environment.md)]
27+
2828
## Sample script
2929

30-
```azurecli-interactive
31-
#!/bin/bash
32-
33-
# Create a resource group.
34-
az group create \
35-
--name myResourceGroup \
36-
--location westeurope
37-
38-
# Create a virtual network.
39-
az network vnet create \
40-
--resource-group myResourceGroup \
41-
--location westeurope \
42-
--name myVnet \
43-
--subnet-name mySubnet
44-
45-
# Create a zonal Standard public IP address.
46-
az network public-ip create \
47-
--resource-group myResourceGroup \
48-
--name myPublicIP \
49-
--sku Standard
50-
--zone 1
51-
52-
# Create an Azure Load Balancer.
53-
az network lb create \
54-
--resource-group myResourceGroup \
55-
--name myLoadBalancer \
56-
--public-ip-address myPublicIP \
57-
--frontend-ip-name myFrontEndPool \
58-
--backend-pool-name myBackEndPool \
59-
--sku Standard
60-
61-
# Creates an LB probe on port 80.
62-
az network lb probe create \
63-
--resource-group myResourceGroup \
64-
--lb-name myLoadBalancer \
65-
--name myHealthProbe \
66-
--protocol tcp \
67-
--port 80
68-
69-
# Creates an LB rule for port 80.
70-
az network lb rule create \
71-
--resource-group myResourceGroup \
72-
--lb-name myLoadBalancer \
73-
--name myLoadBalancerRuleWeb \
74-
--protocol tcp \
75-
--frontend-port 80 \
76-
--backend-port 80 \
77-
--frontend-ip-name myFrontEndPool \
78-
--backend-pool-name myBackEndPool \
79-
--probe-name myHealthProbe
80-
81-
# Create three NAT rules for port 22.
82-
for i in `seq 1 3`; do
83-
az network lb inbound-nat-rule create \
84-
--resource-group myResourceGroup \
85-
--lb-name myLoadBalancer \
86-
--name myLoadBalancerRuleSSH$i \
87-
--protocol tcp \
88-
--frontend-port 422$i \
89-
--backend-port 22 \
90-
--frontend-ip-name myFrontEndPool
91-
done
92-
93-
# Create a network security group
94-
az network nsg create \
95-
--resource-group myResourceGroup \
96-
--name myNetworkSecurityGroup
97-
98-
# Create a network security group rule for port 22.
99-
az network nsg rule create \
100-
--resource-group myResourceGroup \
101-
--nsg-name myNetworkSecurityGroup \
102-
--name myNetworkSecurityGroupRuleSSH \
103-
--protocol tcp \
104-
--direction inbound \
105-
--source-address-prefix '*' \
106-
--source-port-range '*' \
107-
--destination-address-prefix '*' \
108-
--destination-port-range 22 \
109-
--access allow \
110-
--priority 1000
111-
112-
# Create a network security group rule for port 80.
113-
az network nsg rule create \
114-
--resource-group myResourceGroup \
115-
--nsg-name myNetworkSecurityGroup \
116-
--name myNetworkSecurityGroupRuleHTTP \
117-
--protocol tcp \
118-
--direction inbound \
119-
--source-address-prefix '*' \
120-
--source-port-range '*' \
121-
--destination-address-prefix '*' \
122-
--destination-port-range 80 \
123-
--access allow \
124-
--priority 2000
125-
126-
# Create three virtual network cards and associate with public IP address and NSG.
127-
for i in `seq 1 3`; do
128-
az network nic create \
129-
--resource-group myResourceGroup \
130-
--name myNic$i \
131-
--vnet-name myVnet \
132-
--subnet mySubnet \
133-
--network-security-group myNetworkSecurityGroup \
134-
--lb-name myLoadBalancer \
135-
--lb-address-pools myBackEndPool \
136-
--lb-inbound-nat-rules myLoadBalancerRuleSSH$i
137-
done
138-
139-
# Create three virtual machines, this creates SSH keys if not present.
140-
for i in `seq 1 3`; do
141-
az vm create \
142-
--resource-group myResourceGroup \
143-
--name myVM$i \
144-
--zone 1 \
145-
--nics myNic$i \
146-
--image UbuntuLTS \
147-
--generate-ssh-keys \
148-
--no-wait
149-
done
30+
[!INCLUDE [cli-launch-cloud-shell-sign-in.md](../../../includes/cli-launch-cloud-shell-sign-in.md)]
15031

151-
```
32+
### Run the script
33+
34+
:::code language="azurecli" source="~/azure_cli_scripts/load-balancer/load-balance-vms-within-specific-availability-zone/load-balance-vms-within-specific-availability-zone.sh" id="FullScript":::
15235

153-
## Clean up deployment
36+
## Clean up resources
15437

155-
Run the following command to remove the resource group, VM, and all related resources.
38+
[!INCLUDE [cli-clean-up-resources.md](../../../includes/cli-clean-up-resources.md)]
15639

15740
```azurecli
158-
az group delete --name myResourceGroup
41+
az group delete --name $resourceGroup
15942
```
16043

161-
## Script explanation
44+
## Sample reference
16245

16346
This script uses the following commands to create a resource group, virtual machine, availability set, load balancer, and all related resources. Each command in the table links to command specific documentation.
16447

@@ -181,4 +64,4 @@ This script uses the following commands to create a resource group, virtual mach
18164

18265
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
18366

184-
Additional Azure Networking CLI script samples can be found in the [Azure Networking documentation](../cli-samples.md).
67+
Additional Azure Networking CLI script samples can be found in the [Azure Networking documentation](../cli-samples.md).

0 commit comments

Comments
 (0)