-
Notifications
You must be signed in to change notification settings - Fork 11
/
create-test-vm.sh
executable file
·42 lines (37 loc) · 1.04 KB
/
create-test-vm.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
#!/bin/bash
RESOURCE_GROUP=$1
VM_NAME=$2
STORAGE_ACCOUNT=$3
CONTAINER=$4
BASE_IMAGE_NAME=$5
REGION=$6
BUILD_ID=$7
VM_USERNAME=$8
VM_PASSWORD=$9
VM_SIZE=${10}
IMAGE_NAME="$BASE_IMAGE_NAME-$BUILD_ID.vhd"
MANAGED_IMAGE_NAME="$BASE_IMAGE_NAME-$BUILD_ID"
#https://docs.microsoft.com/en-us/azure/storage/common/authorize-data-operations-cli
KEY=$(az storage account keys list \
-n $STORAGE_ACCOUNT \
--query [0].value \
-o tsv)
IMAGE_URL=$(az storage blob url \
--container-name $CONTAINER \
--name $IMAGE_NAME \
--auth-mode key \
--account-key $KEY \
--account-name $STORAGE_ACCOUNT -o tsv)
az image create \
-g $RESOURCE_GROUP\
--name $MANAGED_IMAGE_NAME \
--os-type Linux \
--source $IMAGE_URL
az vm create \
-g $RESOURCE_GROUP \
--name $VM_NAME \
--image $MANAGED_IMAGE_NAME \
--admin-username $VM_USERNAME \
--admin-password $VM_PASSWORD \
--boot-diagnostics-storage $STORAGE_ACCOUNT \
--size $VM_SIZE