-
Notifications
You must be signed in to change notification settings - Fork 7
/
05_01_Deploy_VM.azurecli
53 lines (43 loc) · 1.6 KB
/
05_01_Deploy_VM.azurecli
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
#Define Deployment Variables
appNamePrefix='tws'
locationDetails=$(cat locationDetails.json)
#Deploy VM NIC
location=$(echo $locationDetails | jq -c '.[] | select(.Region | match("Primary")) | .Location' -r)
resourceGroupName="${appNamePrefix}-iaas-${location}"
vmName="${appNamePrefix}admin${location}"
nicName="${appNamePrefix}admin${location}-nic"
vNetName="$appNamePrefix-vnet-$location"
subnetName='AdminSubnet'
az network nic create \
--name ${nicName} \
--resource-group ${resourceGroupName} \
--location ${location} \
--vnet-name ${vNetName} \
--subnet ${subnetName}
#Deploy admin Virtual Machine
#Define Deployment Variables
location=$(echo $locationDetails | jq -c '.[] | select(.Region | match("Primary")) | .Location' -r)
resourceGroupName="${appNamePrefix}-iaas-${location}"
storageAccount=$(az storage account list --resource-group ${resourceGroupName})
storageAccountName=$(echo $storageAccount | jq '.[0].name' -r)
nic=$(az network nic list --resource-group ${resourceGroupName})
nicName=$(echo $nic | jq '.[0].name' -r)
vmName="${appNamePrefix}admin"
osDiskName="${appNamePrefix}admin${location}-os"
vmImage='Win2019Datacenter'
vmSize='Standard_DS2_v2'
adminUser='twsadmin'
adminPassword='P@ssw0rd220475'
#Deploy VM
az vm create \
--name ${vmName} \
--resource-group ${resourceGroupName} \
--location ${location} \
--image ${vmImage} \
--boot-diagnostics-storage ${storageAccountName} \
--size ${vmSize} \
--authentication password \
--admin-username ${adminUser} \
--admin-password ${adminPassword} \
--nics ${nicName} \
--os-disk-name ${osDiskName}