-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-image-info.sh
44 lines (32 loc) · 1.12 KB
/
get-image-info.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
#!/usr/bin/env bash
LOCATION="uksouth"
PUBLISHER="MicrosoftWindowsServer"
OFFER="WindowsServer"
SKU="2019-Datacenter-with-Containers"
###
az vm image list-publishers \
--location ${LOCATION} \
-o table > "AzurePublisherList$(date +'%d%m%Y').txt"
az vm image list-offers \
--location ${LOCATION} \
--publisher ${PUBLISHER} \
-o table > "Azure${PUBLISHER}OfferList$(date +'%d%m%Y').txt"
az vm image list-skus \
--location ${LOCATION} \
--offer ${OFFER} \
--publisher ${PUBLISHER} \
-o table > "Azure${PUBLISHER}SkuList$(date +'%d%m%Y').txt"
if [ -n "$(az vm image list --publisher ${PUBLISHER} --sku ${SKU} --all --query \
"[?offer=='${OFFER}'].version" -o tsv | sort -u | tail -n 1)" ]; then
latest="$(az vm image list --publisher ${PUBLISHER} --sku ${SKU} --all --query \
"[?offer=='${OFFER}'].version" -o tsv | sort -u | tail -n 1)"
az vm image show \
--location ${LOCATION} \
--offer ${OFFER} \
--publisher ${PUBLISHER} \
--sku ${SKU} \
--version ${latest} \
-o table > "Azure${PUBLISHER}${OFFER}LatestValues$(date +'%d%m%Y').txt"
else
echo "No ${VERSION} has been found, skipping"
fi