-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-high-availabilty-vm-with-sets.sh
More file actions
67 lines (60 loc) · 1.98 KB
/
create-high-availabilty-vm-with-sets.sh
File metadata and controls
67 lines (60 loc) · 1.98 KB
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
#!/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
# 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 UbuntuLTS \
--availability-set portalAvailabilitySet \
--generate-ssh-keys \
--custom-data cloud-init.txt
done
# Done
echo '--------------------------------------------------------'
echo ' VM Setup Script Completed'
echo '--------------------------------------------------------'
echo ' Now visit the Azure portal to setup the Load Balancer'
echo ' https://portal.azure.com/learn.docs.microsoft.com'
echo '--------------------------------------------------------'
date