-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsetup_environment.sh
More file actions
69 lines (53 loc) · 2.25 KB
/
Copy pathsetup_environment.sh
File metadata and controls
69 lines (53 loc) · 2.25 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
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
###############################################################################
# Usage:
# ./setup_environment.sh <deploymentName> <location> [--is-local]
################################################################################
set -eu
# Setup STDERR.
err() {
echo "(!) $*" >&2
}
# Validate arguments
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <deploymentName> <location> [--is-local]" >&2
exit 1
fi
DEPLOYMENT_NAME="$1"
LOCATION="$2"
IS_LOCAL=false
# Check for --is-local in arguments
if [ "$#" -eq 3 ] && [ "$3" = "--is-local" ]; then
IS_LOCAL=true
fi
echo "Starting environment setup..."
echo "Deploying infrastructure..."
INFRASTRUCTURE_OUTPUTS=$(bash ./infra/scripts/deploy_infrastructure.sh \
"$DEPLOYMENT_NAME" \
"$LOCATION")
if [ -z "$INFRASTRUCTURE_OUTPUTS" ]; then
echo "Failed to deploy infrastructure." >&2
exit 1
fi
AZURE_AI_SERVICES_ENDPOINT=$(echo "$INFRASTRUCTURE_OUTPUTS" | jq -r '.environmentInfo.value.azureAIServicesEndpoint')
AZURE_OPENAI_ENDPOINT=$(echo "$INFRASTRUCTURE_OUTPUTS" | jq -r '.environmentInfo.value.azureOpenAIEndpoint')
AZURE_OPENAI_CHAT_DEPLOYMENT=$(echo "$INFRASTRUCTURE_OUTPUTS" | jq -r '.environmentInfo.value.azureOpenAIChatDeployment')
AZURE_STORAGE_ACCOUNT=$(echo "$INFRASTRUCTURE_OUTPUTS" | jq -r '.environmentInfo.value.azureStorageAccount')
echo "Updating ./src/AIDocumentPipeline/local.settings.json..."
jq --arg endpoint "$AZURE_AI_SERVICES_ENDPOINT" \
--arg openai_endpoint "$AZURE_OPENAI_ENDPOINT" \
--arg openai_deployment "$AZURE_OPENAI_CHAT_DEPLOYMENT" \
--arg storage_account "$AZURE_STORAGE_ACCOUNT" \
'.Values.AZURE_AISERVICES_ENDPOINT = $endpoint |
.Values.AZURE_OPENAI_ENDPOINT = $openai_endpoint |
.Values.AZURE_OPENAI_CHAT_DEPLOYMENT = $openai_deployment |
.Values.AZURE_STORAGE_ACCOUNT = $storage_account' \
./src/AIDocumentPipeline/local.settings.json > ./src/AIDocumentPipeline/local.settings.json.tmp
mv ./src/AIDocumentPipeline/local.settings.json.tmp ./src/AIDocumentPipeline/local.settings.json
if [ "$IS_LOCAL" = true ]; then
echo "Starting local environment..."
docker-compose up
else
echo "Deploying AI Document Pipeline app to Azure..."
bash ./infra/scripts/deploy_app.sh ./infra/scripts/InfrastructureOutputs.json
fi