-
Notifications
You must be signed in to change notification settings - Fork 7
/
03_01_Deploy_Web_App.azurecli
59 lines (49 loc) · 1.86 KB
/
03_01_Deploy_Web_App.azurecli
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
#Check the subscription
az account show
#List all subscription's
az account list --all --output table
#Set the right subscription
az account set --subscription "Microsoft Azure Sponsorship"
#Define Deployment Variables
appNamePrefix='tws'
locations=(
"westeurope"
"northeurope"
)
#Create ARM Resource Groups
for i in "${locations[@]}"; do
resourceGroupName="${appNamePrefix}-paas-${i}"
az group create --name ${resourceGroupName} --location ${i} \
--output table
done
#Create App Service Plans
for i in "${locations[@]}"; do
#Define Deployment Variables
resourceGroupName="${appNamePrefix}-paas-${i}"
resourceGroup=$(az group show --name ${resourceGroupName} --output json)
resourceGroupLocation=$(echo $resourceGroup | jq .location -r)
appServicePlanName="${appNamePrefix}-plan-${resourceGroupLocation}"
#Deploy App Service Plans
az appservice plan create \
--resource-group $(echo $resourceGroup | jq .name -r) \
--name ${appServicePlanName} \
--location $(echo $resourceGroup | jq .location -r) \
--sku S1 \
--output none
done
#Create Web Apps
for i in "${locations[@]}"; do
#Define Deployment Variables
resourceGroupName="${appNamePrefix}-paas-${i}"
resourceGroup=$(az group show --name ${resourceGroupName} --output json)
resourceGroupLocation=$(echo $resourceGroup | jq .location -r)
resourceGroupId=$(echo $resourceGroup | jq .id -r | shasum)
nameSuffix="${resourceGroupId:0:4}"
webAppName="${appNamePrefix}-web-${resourceGroupLocation}-${nameSuffix}"
appServicePlanName="${appNamePrefix}-plan-${resourceGroupLocation}"
#Deploy Web Apps
az webapp create \
--resource-group $(echo $resourceGroup | jq .name -r) \
--name ${webAppName} \
--plan ${appServicePlanName}
done