This repository has been archived by the owner on Oct 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
AzureVMcreate.sh
106 lines (91 loc) · 3.72 KB
/
AzureVMcreate.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
# Copyright 2018 MapD Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Login using Azure CLI tools
# Install locally: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
# This is necessary to run locally, but not part of automated script
# az login
#To delete entire resource group cleanly
#
#az group delete --name MapDAzure --no-wait -y
# Create resource group
# Putting all resources in same group allows for deleting with single command later
#
az group create --name MapDAzure --location eastus
# Create network security group and open necessary ports
#
az network nsg create --resource-group MapDAzure --name NSGMapDAzure
az network nsg rule create --resource-group MapDAzure --nsg-name NSGMapDAzure --priority 100 --name SSH --destination-port-range 22
az network nsg rule create --resource-group MapDAzure --nsg-name NSGMapDAzure --priority 110 --name HTTP --destination-port-range 80
az network nsg rule create --resource-group MapDAzure --nsg-name NSGMapDAzure --priority 120 --name HTTPS --destination-port-range 443
az network nsg rule create --resource-group MapDAzure --nsg-name NSGMapDAzure --priority 200 --name mapd_ports --destination-port-range 9090-9093
az network nsg rule create --resource-group MapDAzure --nsg-name NSGMapDAzure --priority 210 --name jupyternotebook --destination-port-range 8888
# Create Public IP
#
az network public-ip create \
--name PUBLICIPMapDAzure \
--resource-group MapDAzure \
--location "eastus" \
--allocation-method Static
# Create virtual network
#
az network vnet create \
--resource-group MapDAzure \
--name VnetMapDAzure \
--subnet-name default
# Create Network Interface Card
#
az network nic create \
--resource-group MapDAzure \
--name NICMapDAzure \
--vnet-name VnetMapDAzure \
--subnet default \
--public-ip-address PUBLICIPMapDAzure \
--network-security-group NSGMapDAzure
# Create VM
# Assumes you already have SSH key created at location ~/.ssh/id_rsa.pub
# Standard_NC6: 1 GPU, Standard_NC12: 2 GPUs, Standard_NC24: 4 GPUs
#
az vm create --resource-group MapDAzure \
--name MapDCE \
--location eastus \
--size Standard_NC6 \
--image UbuntuLTS \
--os-disk-size-gb 1023 \
--ssh-key-value ~/.ssh/id_rsa.pub \
--nics NICMapDAzure \
--admin-username mapdadmin \
--storage-sku Standard_LRS \
--verbose
pubip=$( az vm show --show-details --resource-group MapDAzure --name MapDCE --query publicIps -otsv )
echo "Congratulations! You have created an Azure VM with the public IP: $pubip"
# ssh into new instance to silently accept key into local known_users
#
ssh -o StrictHostKeyChecking=accept-new mapdadmin@$pubip pwd
# Copy MapD install and startup scripts to Azure VM
#
scp MapDinstall.sh mapdadmin@$pubip:/home/mapdadmin/
scp StartMapD.sh mapdadmin@$pubip:/home/mapdadmin/
# Put StartMapD into cron, to run after each reboot
#
ssh mapdadmin@$pubip << EOF
crontab -l > mapd_start
echo "@reboot bash /home/mapdadmin/StartMapD.sh &" >> mapd_start
crontab mapd_start
rm mapd_start
EOF
# Install MapD...will reboot after install
#
ssh mapdadmin@$pubip bash MapDinstall.sh
echo "After VM reboots, MapD Immerse can be accessed at $pubip:9092"
echo "Make take several minutes (<5m) for Immerse to be available after reboot"