Skip to content

Commit

Permalink
updated deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
yorek committed Oct 20, 2020
1 parent 1cc5eb8 commit 1b44e87
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions azure-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,33 @@ location="WestUS2"
# Change this if you are using your own github repository
gitSource="https://github.com/Azure-Samples/azure-sql-db-dotnet-rest-api.git"


# Azure configuration
FILE=".env"
if [[ -f $FILE ]]; then
echo "loading from .env"
export $(egrep . $FILE | xargs -n1)
else
cat << EOF > .env
ConnectionStrings__ReadWriteConnection="Server=.database.windows.net;Database=;UID=;PWD="
ConnectionStrings__ReadOnlyConnection="Server=.database.windows.net;Database=;UID=;PWD="
EOF
echo "Enviroment file not detected."
echo "Please configure values for your environment in the created .env file"
echo "and run the script again."
echo "ConnectionStrings__ReadWriteConnection: Azure SQL Connection String used for Read/Write workloads"
echo "ConnectionStrings__ReadOnlyConnection: Azure SQL Connection String used for Read-Only workloads"
exit 1
fi

# Make sure connection string variable is set
if [[ -z "${ConnectionStrings__DefaultConnection:-}" ]]; then
echo "Please export Azure SQL connection string:";
echo "export ConnectionStrings__DefaultConnection=\"your-connection-string-here\"";
if [[ -z "${ConnectionStrings__ReadWriteConnection:-}" ]]; then
echo "ConnectionStrings__ReadWriteConnection not found."
exit 1;
fi

if [[ -z "${ConnectionStrings__ReadOnlyConnection:-}" ]]; then
echo "ConnectionStrings__ReadOnlyConnection not found."
exit 1;
fi

Expand All @@ -40,7 +63,13 @@ echo "Configuring Connection String...";
az webapp config connection-string set \
-g $resourceGroup \
-n $appName \
--settings DefaultConnection=$ConnectionStrings__DefaultConnection \
--settings ReadWriteConnection=$ConnectionStrings__ReadWriteConnection \
--connection-string-type=SQLAzure

az webapp config connection-string set \
-g $resourceGroup \
-n $appName \
--settings ReadOnlyConnection=$ConnectionStrings__ReadOnlyConnection \
--connection-string-type=SQLAzure

echo "Done."

0 comments on commit 1b44e87

Please sign in to comment.