-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathsetup.sh
140 lines (111 loc) · 3.88 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
RgName=`az group list --query '[0].name' --output tsv`
Location=`az group list --query '[0].location' --output tsv`
date
# Create a Virtual Network for the VMs
echo '------------------------------------------'
echo 'Creating a Virtual Network for the VMs'
az network vnet create \
--resource-group $RgName \
--location $Location \
--name bePortalVnet \
--subnet-name bePortalSubnet
# Create a Network Security Group
echo '------------------------------------------'
echo 'Creating a Network Security Group'
az network nsg create \
--resource-group $RgName \
--name bePortalNSG \
--location $Location
az network nsg rule create -g $RgName --nsg-name bePortalNSG -n AllowAll80 --priority 101 \
--source-address-prefixes 'Internet' --source-port-ranges '*' \
--destination-address-prefixes '*' --destination-port-ranges 80 --access Allow \
--protocol Tcp --description "Allow all port 80 traffic"
# Create the NIC
for i in `seq 1 2`; do
echo '------------------------------------------'
echo 'Creating webNic'$i
az network nic create \
--resource-group $RgName \
--name webNic$i \
--vnet-name bePortalVnet \
--subnet bePortalSubnet \
--network-security-group bePortalNSG \
--location $Location
done
# Create an availability set
echo '------------------------------------------'
echo 'Creating an availability set'
az vm availability-set create \
--resource-group $RgName \
--name portalAvailabilitySet
# Create 2 VM's from a template
for i in `seq 1 2`; do
echo '------------------------------------------'
echo 'Creating webVM'$i
az vm create \
--admin-username azureuser \
--resource-group $RgName \
--name webVM$i \
--nics webNic$i \
--location $Location \
--image Ubuntu2204 \
--availability-set portalAvailabilitySet \
--generate-ssh-keys \
--custom-data cloud-init.txt
done
# Done
echo '--------------------------------------------------------'
echo ' VM Setup Completed'
echo '--------------------------------------------------------'
echo '--------------------------------------------------------'
echo ' Starting Load Balancer Deploy'
echo '--------------------------------------------------------'
az network public-ip create \
--resource-group $RgName \
--location $Location \
--allocation-method Static \
--name myPublicIP \
--sku Standard
az network lb create \
--resource-group $RgName \
--name myLoadBalancer \
--public-ip-address myPublicIP \
--frontend-ip-name myFrontEndPool \
--backend-pool-name myBackEndPool \
--sku Standard
az network lb probe create \
--resource-group $RgName \
--lb-name myLoadBalancer \
--name myHealthProbe \
--protocol tcp \
--port 80
az network lb rule create \
--resource-group $RgName \
--lb-name myLoadBalancer \
--name myHTTPRule \
--protocol tcp \
--frontend-port 80 \
--backend-port 80 \
--frontend-ip-name myFrontEndPool \
--backend-pool-name myBackEndPool
az network nic ip-config update \
--resource-group $RgName \
--nic-name webNic1 \
--name ipconfig1 \
--lb-name myLoadBalancer \
--lb-address-pools myBackEndPool
az network nic ip-config update \
--resource-group $RgName \
--nic-name webNic2 \
--name ipconfig1 \
--lb-name myLoadBalancer \
--lb-address-pools myBackEndPool
az network public-ip show \
--resource-group $RgName \
--name myPublicIP \
--query [ipAddress] \
--output tsv
echo '--------------------------------------------------------'
echo ' Load balancer deployed to the IP Address shown above'
echo '--------------------------------------------------------'