-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·56 lines (47 loc) · 1.28 KB
/
deploy.sh
File metadata and controls
executable file
·56 lines (47 loc) · 1.28 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Variables
RESOURCE_GROUP="rg-pgflex-bicep"
LOCATION='westeurope'
CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)"
ENVIRONMENT=$(az account show --query environmentName --output tsv)
# Change the current directory to the script's directory
cd "$CURRENT_DIR" || exit
# Choose the appropriate CLI based on the environment
if [[ $ENVIRONMENT == "LocalStack" ]]; then
echo "Using azlocal for LocalStack emulator environment."
AZ="azlocal"
else
echo "Using standard az for AzureCloud environment."
AZ="az"
fi
# Create resource group
echo "Creating resource group [$RESOURCE_GROUP]..."
$AZ group create \
--name "$RESOURCE_GROUP" \
--location "$LOCATION" \
--output table
if [[ $? != 0 ]]; then
echo "Failed to create resource group. Exiting."
exit 1
fi
# Deploy Bicep template
echo "Deploying Bicep template..."
$AZ deployment group create \
--resource-group "$RESOURCE_GROUP" \
--template-file main.bicep \
--parameters main.bicepparam \
--output table
if [[ $? != 0 ]]; then
echo "Bicep deployment failed. Exiting."
exit 1
fi
# Get deployment outputs
echo ""
echo "=== Deployment Outputs ==="
$AZ deployment group show \
--resource-group "$RESOURCE_GROUP" \
--name main \
--query "properties.outputs" \
--output json
echo ""
echo "Bicep deployment completed successfully."