@@ -10,10 +10,33 @@ location="WestUS2"
10
10
# Change this if you are using your own github repository
11
11
gitSource=" https://github.com/Azure-Samples/azure-sql-db-dotnet-rest-api.git"
12
12
13
+
14
+ # Azure configuration
15
+ FILE=" .env"
16
+ if [[ -f $FILE ]]; then
17
+ echo " loading from .env"
18
+ export $( egrep . $FILE | xargs -n1)
19
+ else
20
+ cat << EOF > .env
21
+ ConnectionStrings__ReadWriteConnection="Server=.database.windows.net;Database=;UID=;PWD="
22
+ ConnectionStrings__ReadOnlyConnection="Server=.database.windows.net;Database=;UID=;PWD="
23
+ EOF
24
+ echo " Enviroment file not detected."
25
+ echo " Please configure values for your environment in the created .env file"
26
+ echo " and run the script again."
27
+ echo " ConnectionStrings__ReadWriteConnection: Azure SQL Connection String used for Read/Write workloads"
28
+ echo " ConnectionStrings__ReadOnlyConnection: Azure SQL Connection String used for Read-Only workloads"
29
+ exit 1
30
+ fi
31
+
13
32
# Make sure connection string variable is set
14
- if [[ -z " ${ConnectionStrings__DefaultConnection:- } " ]]; then
15
- echo " Please export Azure SQL connection string:" ;
16
- echo " export ConnectionStrings__DefaultConnection=\" your-connection-string-here\" " ;
33
+ if [[ -z " ${ConnectionStrings__ReadWriteConnection:- } " ]]; then
34
+ echo " ConnectionStrings__ReadWriteConnection not found."
35
+ exit 1;
36
+ fi
37
+
38
+ if [[ -z " ${ConnectionStrings__ReadOnlyConnection:- } " ]]; then
39
+ echo " ConnectionStrings__ReadOnlyConnection not found."
17
40
exit 1;
18
41
fi
19
42
@@ -40,7 +63,13 @@ echo "Configuring Connection String...";
40
63
az webapp config connection-string set \
41
64
-g $resourceGroup \
42
65
-n $appName \
43
- --settings DefaultConnection=$ConnectionStrings__DefaultConnection \
66
+ --settings ReadWriteConnection=$ConnectionStrings__ReadWriteConnection \
67
+ --connection-string-type=SQLAzure
68
+
69
+ az webapp config connection-string set \
70
+ -g $resourceGroup \
71
+ -n $appName \
72
+ --settings ReadOnlyConnection=$ConnectionStrings__ReadOnlyConnection \
44
73
--connection-string-type=SQLAzure
45
74
46
75
echo " Done."
0 commit comments