-
Notifications
You must be signed in to change notification settings - Fork 0
/
msft-cli
executable file
·56 lines (39 loc) · 2.49 KB
/
msft-cli
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
#!/bin/bash
#azure login
#azure config mode arm
{ ## Save all the output for later please
# source the parameters file
. ./$1
echo Building OpenVPN SSL Routing Group .. Main Resource group is $rg
echo ------------------------------------------------------------------------------
date
#create the resoure group
azure group create $rg $location -t $tags
#Create storage account ... this is currently taking too long so fork it to the background
azure storage account create $storageaccount --sku-name $storageaccounttype -g $rg -l $location --tags $tags --kind $storageaccountkind
## Create Vnets
azure network vnet create $rg $vnet $location -t $tags -a $vnetprefix -d $dnsservers
azure network route-table create $rg $routetable $location -t $tags
azure network route-table route create $rg $routetable -n $routename $openvpnrouteprefix VirtualAppliance -p $vm1nicip
#create nsg
azure network nsg create $rg $nsgname $location -t $tags
azure network nsg rule create $rg $nsgname $nsgrule1 $nsgrule1priority -p $nsg1protocol -u $nsg1port
azure network nsg rule create $rg $nsgname $nsgrule2 $nsgrule2priority -p $nsg2protocol -u $nsg2port
#create public IP
azure network public-ip create $rg $vm1publicipname $location -t $tags -a $vm1publicipallocation
#create subnet and set the security group on that
azure network vnet subnet create $rg $vnet $subnetname $subnetprefix -r $routetable -o $nsgname
# create the first nic
azure network nic create $rg $vm1nic $location --enable-ip-forwarding true --subnet-name $subnetname --subnet-vnet-name $vnet -p $vm1publicipname -a $vm1nicip -t $tags
# create the second nic
azure network nic create $rg $vm2nic $location --subnet-name $subnetname --subnet-vnet-name $vnet -a $vm2nicip -t $tags
#create first vm
azure vm create $rg $vm1name $location $vm1ostype -f $vm1nic -Q $vm1imageurn -u $vm1adminusername -M $vm1sshkey -o $storageaccount -z $vm1size
#call automation to build to install OpenVPN onto this machine
azure vm extension set $rg $vm1name CustomScript Microsoft.Azure.Extensions 2.0 --auto-upgrade-minor-version --public-config '{"fileUris": ["https://raw.githubusercontent.com/stephenhickie/azure-ovpn/master/install-setup-ovpn.sh"],"commandToExecute": "sudo bash -x ./install-setup-ovpn.sh"}'
#create second vm
azure vm create $rg $vm2name $location $vm2ostype -f $vm2nic -Q $vm2imageurn -u $vm2adminusername -M $vm2sshkey -o $storageaccount -z $vm1size
echo All done, if the God of Demos has been kind
echo -------------------------------------------
date
} 2>&1 | tee -a $2