Skip to content

Commit b3be121

Browse files
committed
feat: update deployment logic to resolve preview revision names for API and UI promotions
1 parent 93930d3 commit b3be121

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

.azdo/pipelines/azure-dev.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,11 +443,40 @@ stages:
443443
exit 1
444444
fi
445445
446+
API_APP_NAME=$(azd env get-values | sed -n 's/^SERVICE_API_NAME="\(.*\)"/\1/p')
447+
UI_APP_NAME=$(azd env get-values | sed -n 's/^SERVICE_UI_NAME="\(.*\)"/\1/p')
448+
449+
API_PREVIEW_REVISION=""
450+
UI_PREVIEW_REVISION=""
451+
452+
if [[ -n "${API_APP_NAME}" ]]; then
453+
API_PREVIEW_REVISION=$(az containerapp ingress traffic show \
454+
--resource-group "${AZURE_RESOURCE_GROUP}" \
455+
--name "${API_APP_NAME}" \
456+
--query "[?label=='${API_PREVIEW_LABEL}'].revisionName | [0]" \
457+
-o tsv 2>/dev/null || true)
458+
fi
459+
460+
if [[ -n "${UI_APP_NAME}" ]]; then
461+
UI_PREVIEW_REVISION=$(az containerapp ingress traffic show \
462+
--resource-group "${AZURE_RESOURCE_GROUP}" \
463+
--name "${UI_APP_NAME}" \
464+
--query "[?label=='${UI_PREVIEW_LABEL}'].revisionName | [0]" \
465+
-o tsv 2>/dev/null || true)
466+
fi
467+
468+
if [[ -z "${API_PREVIEW_REVISION}" || -z "${UI_PREVIEW_REVISION}" ]]; then
469+
echo "Unable to resolve preview revision names for promotion."
470+
echo "API preview revision: ${API_PREVIEW_REVISION:-<none>}"
471+
echo "UI preview revision: ${UI_PREVIEW_REVISION:-<none>}"
472+
exit 1
473+
fi
474+
446475
echo "Promoting API from package: ${API_PACKAGE_REF}"
447-
azd deploy api --from-package "${API_PACKAGE_REF}" --no-prompt
476+
API_PRODUCTION_REVISION_NAME="${API_PREVIEW_REVISION}" azd deploy api --from-package "${API_PACKAGE_REF}" --no-prompt
448477
449478
echo "Promoting UI from package: ${UI_PACKAGE_REF}"
450-
azd deploy ui --from-package "${UI_PACKAGE_REF}" --no-prompt
479+
UI_PRODUCTION_REVISION_NAME="${UI_PREVIEW_REVISION}" azd deploy ui --from-package "${UI_PACKAGE_REF}" --no-prompt
451480
env:
452481
AZURE_SUBSCRIPTION_ID: $(azureSubscriptionId)
453482
AZURE_ENV_NAME: $(azureEnvName)
@@ -458,9 +487,11 @@ stages:
458487
UI_ACTIVE_LABEL: $(uiActiveLabel)
459488
UI_PROMOTE_PREVIEW: "true"
460489
UI_PRODUCTION_REVISION_NAME: ""
490+
UI_PREVIEW_LABEL: $(uiPreviewLabel)
461491
API_ACTIVE_LABEL: $(apiActiveLabel)
462492
API_PROMOTE_PREVIEW: "true"
463493
API_PRODUCTION_REVISION_NAME: ""
494+
API_PREVIEW_LABEL: $(apiPreviewLabel)
464495
API_PACKAGE_REF: $(apiPackageRef)
465496
UI_PACKAGE_REF: $(uiPackageRef)
466497
VITE_APP_VERSION: $(uiSemVerVersionTag)

infra/api.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing
4141
var previewLabel = activeLabel == 'blue' ? 'green' : 'blue'
4242
var productionLabel = promotePreview ? previewLabel : activeLabel
4343
var targetLabel = promotePreview ? productionLabel : previewLabel
44-
var useLatestForProductionTraffic = promotePreview || empty(productionRevisionName)
44+
var useLatestForProductionTraffic = empty(productionRevisionName)
4545
var previewTrafficEntry = {
4646
label: previewLabel
4747
latestRevision: true

infra/ui.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2025-
2020
var previewLabel = activeLabel == 'blue' ? 'green' : 'blue'
2121
var productionLabel = promotePreview ? previewLabel : activeLabel
2222
var targetLabel = promotePreview ? productionLabel : previewLabel
23-
var useLatestForProductionTraffic = promotePreview || empty(productionRevisionName)
23+
var useLatestForProductionTraffic = empty(productionRevisionName)
2424
var previewTrafficEntry = {
2525
label: previewLabel
2626
latestRevision: true

0 commit comments

Comments
 (0)