Repository navigation
Expand file tree
/
Copy pathdeploy-function-code.sh
More file actions
49 lines (41 loc) · 1.8 KB
/
Copy pathdeploy-function-code.sh
File metadata and controls
49 lines (41 loc) · 1.8 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
#!/bin/bash
# Ev2 shell extension: zip-deploy the LocalDependencyCache Function App code.
#
# Environment (from Parameters/DeployFunctionCode.Rollout.Parameters.json):
# RESOURCE_GROUP resource group Ev2 deployed the infrastructure into
# FUNCTION_PACKAGE_SAS read-only SAS URL for Build/functionapp.zip
# Runs as the ldcache-deploy user-assigned identity (Website Contributor on the Function App).
set -euo pipefail
: "${RESOURCE_GROUP:?RESOURCE_GROUP is not set}"
: "${FUNCTION_PACKAGE_SAS:?FUNCTION_PACKAGE_SAS is not set}"
echo "Signing in with the deployment managed identity"
az login --identity --output none
# The Function App name contains a deployment-time hash; find it by its application tag.
app_name=$(az functionapp list --resource-group "$RESOURCE_GROUP" \
--query "[?tags.application=='LocalDependencyCache'].name | [0]" --output tsv)
if [[ -z "$app_name" ]]; then
echo "No LocalDependencyCache Function App found in resource group $RESOURCE_GROUP" >&2
exit 1
fi
echo "Function App: $app_name"
package=$(mktemp --suffix=.zip)
trap 'rm -f "$package"' EXIT
curl --fail --silent --show-error --retry 3 --output "$package" "$FUNCTION_PACKAGE_SAS"
echo "Downloaded package: $(stat --format=%s "$package") bytes"
az functionapp deployment source config-zip \
--resource-group "$RESOURCE_GROUP" \
--name "$app_name" \
--src "$package" \
--output none
# Function indexing can lag briefly behind a Flex Consumption deployment.
for attempt in $(seq 1 12); do
functions=$(az functionapp function list --resource-group "$RESOURCE_GROUP" --name "$app_name" \
--query "[].name" --output tsv)
if grep -q "SyncCacheTimerFunction" <<< "$functions"; then
echo "Deployed. Functions: $functions"
exit 0
fi
sleep 10
done
echo "SyncCacheTimerFunction was not found after deployment" >&2
exit 1