@@ -12,6 +12,13 @@ parameters:
1212 - dev
1313 - preview
1414 - prod
15+ - name : slot
16+ displayName : ' Target Slot'
17+ type : string
18+ default : default
19+ values :
20+ - default
21+ - authoring
1522
1623variables :
1724 - template : /eng/pipelines/templates/variables/globals.yml
@@ -117,21 +124,30 @@ extends:
117124 scriptLocation : inlineScript
118125 inlineScript : |
119126 set -euo pipefail
120- echo "Updating container image $(imageName):$(imageTag) for app $(APP_NAME)"
127+ SLOT="${{ parameters.slot }}"
128+ if [ -n "$SLOT" ] && [ "$SLOT" != "default" ]; then
129+ TARGET="$(APP_NAME)/$SLOT"
130+ SLOT_ARG="--slot $SLOT"
131+ else
132+ TARGET="$(APP_NAME)"
133+ SLOT_ARG=""
134+ fi
135+ echo "Updating container image $(imageName):$(imageTag) for app $TARGET"
121136 ACR_LOGIN_SERVER=$(az acr show --name "$(ACR_NAME)" --resource-group "$(ACR_RESOURCE_GROUP)" --query loginServer -o tsv)
122137 echo "ACR: $ACR_LOGIN_SERVER"
123138 set +e
124139 OUTPUT=$(az webapp config container set \
125140 --name "$(APP_NAME)" \
126141 --resource-group "$(RESOURCE_GROUP)" \
142+ $SLOT_ARG \
127143 --container-image-name "$ACR_LOGIN_SERVER/$(imageName):$(imageTag)" \
128144 --container-registry-url "https://$ACR_LOGIN_SERVER" 2>&1)
129145 STATUS=$?
130146 set -euo pipefail
131147 echo "$OUTPUT"
132148 [ $STATUS -eq 0 ] || { echo "Failed to update container" >&2; exit $STATUS; }
133149 echo "Container configuration updated"
134- az webapp restart --name "$(APP_NAME)" --resource-group "$(RESOURCE_GROUP)"
150+ az webapp restart --name "$(APP_NAME)" --resource-group "$(RESOURCE_GROUP)" $SLOT_ARG
135151 echo "Webapp restart requested"
136152 env :
137153 APP_NAME : $(APP_NAME)
@@ -150,7 +166,15 @@ extends:
150166 scriptLocation : inlineScript
151167 inlineScript : |
152168 set -euo pipefail
153- APP_URL=$(az webapp show --name "$(APP_NAME)" --resource-group "$(RESOURCE_GROUP)" --query defaultHostName -o tsv)
169+ SLOT="${{ parameters.slot }}"
170+ if [ -n "$SLOT" ] && [ "$SLOT" != "default" ]; then
171+ TARGET="$(APP_NAME)/$SLOT"
172+ SLOT_ARG="--slot $SLOT"
173+ else
174+ TARGET="$(APP_NAME)"
175+ SLOT_ARG=""
176+ fi
177+ APP_URL=$(az webapp show --name "$(APP_NAME)" --resource-group "$(RESOURCE_GROUP)" $SLOT_ARG --query defaultHostName -o tsv)
154178 echo "App URL: https://$APP_URL"
155179 echo "Waiting for health..."; sleep 25
156180 HTTP_STATUS=$(curl -s -o /dev/null -w '%{http_code}' https://$APP_URL/ping || echo 000)
@@ -162,9 +186,10 @@ extends:
162186 ACR_LOGIN_SERVER=$(az acr show --name "$(ACR_NAME)" --resource-group "$(ACR_RESOURCE_GROUP)" --query loginServer -o tsv)
163187 echo "=== Deployment Summary ==="
164188 echo "Environment: ${{ parameters.environment }}"
189+ echo "Slot: ${{ parameters.slot }}"
165190 echo "Image Tag: $(imageTag)"
166191 echo "Resource Group: $(RESOURCE_GROUP)"
167- echo "App Service: $(APP_NAME) "
192+ echo "App Service: $TARGET "
168193 echo "Image: $ACR_LOGIN_SERVER/$(imageName):$(imageTag)"
169194 echo "Health Status: $HTTP_STATUS"
170195 echo "URL: https://$APP_URL"
0 commit comments