Skip to content

Commit 040e28a

Browse files
feat: Automate Web App restarts in CD (#227)
* Update and rename function-apps-restart.yaml to app-services-restart.yaml * Update app-services-restart.yaml
1 parent d04f2c6 commit 040e28a

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

.azuredevops/templates/steps/function-apps-restart.yaml renamed to .azuredevops/templates/steps/app-services-restart.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ parameters:
77
steps:
88
- task: AzureCLI@2
99
name: deploy_images
10-
displayName: Restart Function Apps
10+
displayName: Restart App Services
1111
inputs:
1212
azureSubscription: ${{ parameters.serviceConnection }}
1313
addSpnToEnvironment: true
@@ -19,7 +19,6 @@ steps:
1919
declare -a pids
2020
2121
wait_for_completion() {
22-
# acr tasks are backgrounded for parallelism
2322
local -n arr=$1
2423
for pid in "${arr[@]}"; do
2524
wait ${pid}
@@ -39,5 +38,18 @@ steps:
3938
4039
pids+=($!)
4140
done
41+
42+
webApps=$(az webapp list --resource-group $(FUNCTION_RESOURCE_GROUP) --query "[].name" -o tsv)
43+
for webApp in $webApps; do
44+
45+
imageName="${PROJECT_NAME}-$(echo $webApp | sed "s/^$(ENVIRONMENT_SHORT)-uks-//")"
46+
47+
# Push the new image to the function app and perform manual restart. Pair the commands to run in parallel:
48+
echo "##[debug] $webApp updating and restarting with image ${SRC_REGISTRY}.azurecr.io/${imageName}:${ADD_IMAGE_TAG}" && \
49+
az webapp restart --name $webApp --resource-group $(FUNCTION_RESOURCE_GROUP) &
50+
51+
pids+=($!)
52+
done
53+
4254
wait_for_completion pids
43-
echo "##[debug] All function apps restarted"
55+
echo "##[debug] All App Services restarted"

0 commit comments

Comments
 (0)