/
demo.azcli
44 lines (31 loc) · 1.7 KB
/
demo.azcli
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
##################################################################################################
# Those commands should be executed from Azure Cloud Shell bash or local bash if you install az tool
##################################################################################################
#make sure you use the latest version
az upgrade
#update the following values from the output of the previous demo
cdnaccount=""
blobaccount=""
#get key
key=$(az storage account keys list --account-name $blobaccount --query "[0].{Name:value}" -o tsv)
#!!!! Important
#replace links to files before upload
sed -i "s/<cdn>/$cdnaccount.azureedge.net/" index.html
#upload HTML to the folder
az storage blob upload --account-name $blobaccount --account-key $key --container-name '$web' --file index.html --name index.html --overwrite
#retrieve Static Url
url=$(az storage account show --name $blobaccount --query "primaryEndpoints.web" --output tsv)
echo $url
#you can visit this URL from your browser and enable F12 tool to monitor the speed
#and compare with what you have on the previous demo.
#if click on the "click me" you will get "hello world!"
#replace links to files before upload
sed -i "s/hello world/Azure Rocks/" demo.js
#upload updated JS with extended TTL to 60 minutes
az storage blob upload --name demo.js --content-cache-control max-age=3600 -f demo.js -c files --account-name $blobaccount --account-key $key --overwrite
echo $url
#if you complete the previous call the minute before you should still get "hello world!"
#lets purge content
az cdn endpoint purge -g AzureCDN-RG --name $cdnaccount --profile-name $cdnaccount --content-paths '/demo.js'
#revisit page again and try click on the button.
echo $url