3
3
set -euo pipefail
4
4
5
5
# Make sure these values are correct for your environment
6
- resourceGroup=" dm-api-03"
7
- appName=" dm-api-03"
6
+ resourceGroup=" dm-api-04"
7
+ appName=" dm-api-04"
8
+ storageName=" dmapi04"
8
9
location=" WestUS2"
9
10
10
11
# Change this if you are using your own github repository
11
12
gitSource=" https://github.com/Azure-Samples/azure-sql-db-node-rest-api.git"
12
13
13
14
# Make sure variables are sent in local.settings.json
14
- if [[ -z " ${SQLAZURECONNSTR_WWIF:- } " ]]; then
15
- echo " Plase export Azure SQL connection string:" ;
16
- echo " export SQLAZURECONNSTR_WWIF=\" your-connection-string-here\" " ;
15
+ if [[ -z " ${db_server:- } " ]]; then
16
+ echo " Please export Azure SQL server to use:" ;
17
+ echo " export db_server=\" your-database-name-here\" .database.windows.net" ;
18
+ exit 1;
19
+ fi
20
+ if [[ -z " ${db_database:- } " ]]; then
21
+ echo " Please export Azure SQL database to use:" ;
22
+ echo " export db_database=\" your-database-name-here\" " ;
17
23
exit 1;
18
24
fi
19
25
@@ -22,13 +28,6 @@ az group create \
22
28
-n $resourceGroup \
23
29
-l $location
24
30
25
- echo " Creating Application Service Plan..." ;
26
- az appservice plan create \
27
- -g $resourceGroup \
28
- -n " linux-plan" \
29
- --sku B1 \
30
- --is-linux
31
-
32
31
echo " Creating Application Insight..."
33
32
az resource create \
34
33
-g $resourceGroup \
@@ -39,26 +38,47 @@ az resource create \
39
38
echo " Reading Application Insight Key..."
40
39
aikey=` az resource show -g $resourceGroup -n $appName -ai --resource-type " Microsoft.Insights/components" --query properties.InstrumentationKey -o tsv`
41
40
42
- echo " Creating Web Application..." ;
43
- az webapp create \
41
+ echo " Creating Storage Account..." ;
42
+ az storage account create \
43
+ -g $resourceGroup \
44
+ -l $location \
45
+ -n $storageName \
46
+ --sku Standard_LRS
47
+
48
+ echo " Creating Function App..." ;
49
+ az functionapp create \
44
50
-g $resourceGroup \
45
51
-n $appName \
46
- --plan " linux-plan" \
47
- --runtime " PYTHON|3.7" \
52
+ --storage-account $storageName \
53
+ --app-insights-key $aikey \
54
+ --consumption-plan-location $location \
48
55
--deployment-source-url $gitSource \
49
- --deployment-source-branch master
56
+ --deployment-source-branch main \
57
+ --functions-version 2 \
58
+ --os-type Windows \
59
+ --runtime node \
60
+ --runtime-version 10 \
61
+
50
62
51
63
echo " Configuring Connection String..." ;
52
- az webapp config connection-string set \
64
+ az functionapp config appsettings set \
65
+ -g $resourceGroup \
66
+ -n $appName \
67
+ --settings " db_server=$db_server "
68
+
69
+ az functionapp config appsettings set \
70
+ -g $resourceGroup \
71
+ -n $appName \
72
+ --settings " db_database=$db_database "
73
+
74
+ az functionapp config appsettings set \
53
75
-g $resourceGroup \
54
76
-n $appName \
55
- --settings WWIF=" $SQLAZURECONNSTR_WWIF " \
56
- --connection-string-type=SQLAzure
77
+ --settings ' db_user=NodeFuncApp'
57
78
58
- echo " Configuring Application Insights..." ;
59
- az webapp config appsettings set \
79
+ az functionapp config appsettings set \
60
80
-g $resourceGroup \
61
81
-n $appName \
62
- --settings APPINSIGHTS_KEY= " $aikey "
82
+ --settings ' db_password=aN0ThErREALLY#$%TRONGpa44w0rd! '
63
83
64
84
echo " Done."
0 commit comments