-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-apim-gw.sh
executable file
·45 lines (33 loc) · 1.14 KB
/
deploy-apim-gw.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
#!/bin/bash
set -e
# infrastructure deployment properties
PROJECT_NAME="$1"
APIM_IMAGE="$2"
APIM_GW_ENDPOINT="$3"
APIM_GW_TOKEN="$4"
if [ "$PROJECT_NAME" == "" ]; then
echo "No project name provided - aborting"
exit 0;
fi
if [ "$APIM_IMAGE" == "" ]; then
echo "No iamge provided - defaulting"
APIM_IMAGE="mcr.microsoft.com/azure-api-management/gateway:2.5.0"
fi
if [[ $PROJECT_NAME =~ ^[a-z0-9]{5,10}$ ]]; then
echo "project name $PROJECT_NAME is valid"
else
echo "project name $PROJECT_NAME is invalid - only numbers and lower case min 5 and max 10 characters allowed - aborting"
exit 0;
fi
RESOURCE_GROUP="$PROJECT_NAME"
AZURE_CORE_ONLY_SHOW_ERRORS="True"
if [ $(az group exists --name $RESOURCE_GROUP) = false ]; then
echo "resource group $RESOURCE_GROUP does not exist"
error=1
else
echo "resource group $RESOURCE_GROUP already exists"
LOCATION=$(az group show -n $RESOURCE_GROUP --query location -o tsv)
fi
az deployment group create -g $RESOURCE_GROUP -f ./infrastructure/apim-gw.bicep \
-p projectName=$PROJECT_NAME -p apimImage=$APIM_IMAGE \
-p apimGwEndpoint=$APIM_GW_ENDPOINT -p apimGwToken=$APIM_GW_TOKEN