-
Notifications
You must be signed in to change notification settings - Fork 35
/
azure-deploy.sh
65 lines (52 loc) · 1.74 KB
/
azure-deploy.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -euo pipefail
# Make sure these values are correct for your environment
resourceGroup="dm-api-01"
appName="dm-api-01"
location="WestUS2"
# Change this if you are using your own github repository
gitSource="https://github.com/Azure-Samples/azure-sql-db-python-rest-api.git"
# Make sure connection string variable is set
if [[ -z "${SQLAZURECONNSTR_WWIF:-}" ]]; then
echo "Plase export Azure SQL connection string:";
echo "export SQLAZURECONNSTR_WWIF=\"your-connection-string-here\"";
exit 1;
fi
echo "Creating Resource Group...";
az group create \
-n $resourceGroup \
-l $location
echo "Creating Application Service Plan...";
az appservice plan create \
-g $resourceGroup \
-n "linux-plan" \
--sku B1 \
--is-linux
echo "Creating Application Insight..."
az resource create \
-g $resourceGroup \
-n $appName-ai \
--resource-type "Microsoft.Insights/components" \
--properties '{"Application_Type":"web"}'
echo "Reading Application Insight Key..."
aikey=`az resource show -g $resourceGroup -n $appName-ai --resource-type "Microsoft.Insights/components" --query properties.InstrumentationKey -o tsv`
echo "Creating Web Application...";
az webapp create \
-g $resourceGroup \
-n $appName \
--plan "linux-plan" \
--runtime "PYTHON|3.7" \
--deployment-source-url $gitSource \
--deployment-source-branch master
echo "Configuring Connection String...";
az webapp config connection-string set \
-g $resourceGroup \
-n $appName \
--settings WWIF="$SQLAZURECONNSTR_WWIF" \
--connection-string-type=SQLAzure
echo "Configuring Application Insights...";
az webapp config appsettings set \
-g $resourceGroup \
-n $appName \
--settings APPINSIGHTS_KEY="$aikey"
echo "Done."