Skip to content
This repository was archived by the owner on Feb 11, 2024. It is now read-only.

Commit 0b11575

Browse files
committed
adding deploy.sh for deployment
1 parent 1a35c27 commit 0b11575

File tree

2 files changed

+48
-10
lines changed

2 files changed

+48
-10
lines changed

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,13 @@ This is especially interesting as, for Event Grid Subscriptions, the target endp
2020

2121
## Deploying locally
2222
1. Open the repo in its VS Code Dev Container (this ensures you have all the right versions of the necessary tooling)
23-
1. run `az login` and `az account set --subscription <target subscription id>` to connect to your Azure Subscription
24-
1. `cd infrastructure/terraform`
25-
1. run `terraform init`
26-
1. run `terraform apply -var prefix=<some unique prefix here> -target module.functions`
27-
1. `cd ../../src/FunctionApp`
28-
1. run `func azure functionapp publish <the name of the functionapp outputted by terraform apply> --csharp`
29-
1. `cd ../../infrastructure/terraform`
30-
1. run `terraform apply -var prefix=<same prefix as before>`
23+
1. run `./deploy.sh <target subscription id> <unique prefix>`
3124

3225
### What it does
33-
- Tells terraform to run everything **except** the event grid subscription piece
26+
- Logs in to Azure and connects to the target subscription
27+
- Tells terraform to deploy everything **except** the event grid subscription piece
3428
- Deploys the function app out to Azure so it's ready to answer the subscription wire-up that Terraform will do next
35-
- Tells terraform to apply **everything**, which issues the necessary changes to Azure to add the event grid subscription to an 'inbox' storage account
29+
- Tells terraform to deploy **everything**, which issues the necessary changes to Azure to add the event grid subscription to an 'inbox' storage account
3630

3731
## Deploying via Azure DevOps
3832
By importing the [azure-piplines.yaml](./azure-pipelines.yaml) file in to an Azure DevOps pipeline, you'll get the same process as the above local execution.

deploy.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#! /bin/bash
2+
3+
if [ $# -lt 2 ]
4+
then
5+
echo "Usage: ./deploy.sh <subscription id> <unique prefix>"
6+
exit 1
7+
fi
8+
9+
az account set --subscription $1 &> /dev/null
10+
if [ $? -ne 0 ]; then
11+
az login > /dev/null
12+
fi
13+
14+
[ $? -ne 0 ] && exit $?
15+
16+
az account set --subscription $1
17+
18+
[ $? -ne 0 ] && exit $?
19+
20+
echo 'Deploying Terraform sandwich "top bun"...'
21+
cd infrastructure/terraform
22+
terraform init -reconfigure -upgrade=true > /dev/null
23+
terraform apply -var prefix=$2 -target module.functions -compact-warnings
24+
25+
[ $? -ne 0 ] && exit $?
26+
27+
cd ../../src/FunctionApp
28+
29+
echo "Deploying Function App..."
30+
sleep 3
31+
func azure functionapp list-functions $2-fxn &> /dev/null
32+
while [ $? -ne 0 ] ;
33+
do
34+
sleep 3
35+
func azure functionapp list-functions $2-fxn &> /dev/null
36+
done
37+
38+
func azure functionapp publish $2-fxn --csharp > /dev/null
39+
40+
[ $? -ne 0 ] && exit $?
41+
42+
echo 'Deploying Terraform sandwich "bottom bun"...'
43+
cd ../../infrastructure/terraform
44+
terraform apply -var prefix=$2 -compact-warnings

0 commit comments

Comments
 (0)