-
Notifications
You must be signed in to change notification settings - Fork 0
/
10-regenerateimage.sh
47 lines (37 loc) · 1.87 KB
/
10-regenerateimage.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
# Setup script variables
aibTemplateFullName=${aibTemplateName}.json
aibDate=$(date +'%d-%m-%Y')
# JSON AIB Template published location
# ** must be available at runtime, so don't forget to commit & push any template changes first!
templateurl=https://raw.githubusercontent.com/timstockford/az_imagebuilder_templates/master/templates/$aibTemplateFullName
curl $templateurl -o $USR_TMPDIR/$aibTemplateFullName
sed -i -e "s/<subscriptionID>/$subscriptionID/g" $USR_TMPDIR/$aibTemplateFullName
sed -i -e "s/<rgName>/$aibResourceGroup/g" $USR_TMPDIR/$aibTemplateFullName
sed -i -e "s/<region>/$location/g" $USR_TMPDIR/$aibTemplateFullName
sed -i -e "s/<sigName>/$sigName/g" $USR_TMPDIR/$aibTemplateFullName
sed -i -e "s/<imageDefName>/$imageDefName/g" $USR_TMPDIR/$aibTemplateFullName
sed -i -e "s/<runOutputName>/$runOutputName/g" $USR_TMPDIR/$aibTemplateFullName
sed -i -e "s/<date>/$aibDate/g" $USR_TMPDIR/$aibTemplateFullName
sed -i -e "s/<aibTemplatePath>/$aibTemplateFullName/g" $USR_TMPDIR/$aibTemplateFullName
# update/upgrade of image templates not currently supported
logc delete existing template image if it already exists
az image builder delete -g $aibResourceGroup -n $aibTemplateName
logc submit the image confiuration to the VM Image Builder Service
logc This may take 1-3mins
az resource create \
--resource-group $aibResourceGroup \
--properties @$USR_TMPDIR/$aibTemplateFullName \
--is-full-object \
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
-n $aibTemplateName
# wait approx 1-3mins, depending on external links
# start the image build
logc This will take approx 15-30 mins ... can vary by region
dt=$(date '+%d/%m/%Y %H:%M:%S');
logc $dt
az resource invoke-action \
--resource-group $aibResourceGroup \
--resource-type Microsoft.VirtualMachineImages/imageTemplates \
-n $aibTemplateName \
--action Run
# wait approx 15mins