From 16213bd8db02826769073286de9495499749c404 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Tue, 6 Jan 2026 11:59:50 -0800 Subject: [PATCH 01/22] feat: change upload logic --- .../templates/.builder-release-template.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index c5885689f69..77a156148ad 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -125,6 +125,23 @@ steps: BUILD_ID: $(Build.BuildId) BUILD_DEFINITION_NAME: $(Build.DefinitionName) + - bash: | + if [ "${ENVIRONMENT,,}" = "tme" ] && [ "${GENERATE_PUBLISHING_INFO,,}" = "true" ] && [ ${RUN_PREFETCH_OPTIMIZATION,,} = "false" ] || [ ${BUILDER} = "imagecustomizer" ]; then + DESTINATION_STORAGE_CONTAINER=${CLASSIC_BLOB_STAGING} + STAGING_CONTAINER_EXISTS=$(az storage container exists --account-name ${STORAGE_ACCOUNT_NAME} --name $VHD_STAGING_CONTAINER_NAME --auth-mode login | jq -r '.exists') + if [ "${STAGING_CONTAINER_EXISTS,,}" = "false" ]; then + echo "Creating staging container $VHD_STAGING_CONTAINER_NAME in storage account $STORAGE_ACCOUNT_NAME" + az storage container create --account-name "$STORAGE_ACCOUNT_NAME" --name "$VHD_STAGING_CONTAINER_NAME" --auth-mode login || exit 1 + else + echo "Staging container $VHD_STAGING_CONTAINER_NAME already exists in storage account $STORAGE_ACCOUNT_NAME" + fi + else + DESTINATION_STORAGE_CONTAINER=${CLASSIC_BLOB} + fi + echo "##vso[task.setvariable variable=DESTINATION_STORAGE_CONTAINER]${DESTINATION_STORAGE_CONTAINER}" + condition: always() + displayName: Set Destination Storage Container + - bash: | PACKER_VNET_RESOURCE_GROUP_NAME="$(cat vhdbuilder/packer/settings.json | grep "vnet_resource_group_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ PACKER_VNET_NAME="$(cat vhdbuilder/packer/settings.json | grep "vnet_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ From da5ce288e39237a4126dc7b534c4cc89445dce3c Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Tue, 6 Jan 2026 12:04:12 -0800 Subject: [PATCH 02/22] fix: storage container destination --- .../packer/convert-sig-to-classic-storage-account-blob.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh b/vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh index 86da1b92d74..d0d284e8f0f 100755 --- a/vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh +++ b/vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh @@ -139,7 +139,7 @@ export AZCOPY_JOB_PLAN_LOCATION="$(pwd)/azcopy-job-plan-files/" mkdir -p "${AZCOPY_LOG_LOCATION}" mkdir -p "${AZCOPY_JOB_PLAN_LOCATION}" -if ! azcopy copy "${sas}" "${CLASSIC_BLOB}/${CAPTURED_SIG_VERSION}.vhd" --recursive=true ; then +if ! azcopy copy "${sas}" "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --recursive=true ; then azExitCode=$? # loop through azcopy log files shopt -s nullglob @@ -159,7 +159,7 @@ if ! azcopy copy "${sas}" "${CLASSIC_BLOB}/${CAPTURED_SIG_VERSION}.vhd" --recurs exit $azExitCode fi -echo "Uploaded $disk_resource_id to ${CLASSIC_BLOB}/${CAPTURED_SIG_VERSION}.vhd" +echo "Uploaded $disk_resource_id to ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" capture_benchmark "${SCRIPT_NAME}_upload_disk_to_blob" if ! az disk revoke-access --ids $disk_resource_id; then From fa505d23125bffbc2793110c7374fc79e2c2ec76 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Tue, 6 Jan 2026 12:14:00 -0800 Subject: [PATCH 03/22] fix --- .../scripts/publish-imagecustomizer-image.sh | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh b/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh index a9c819e5fae..b63d33c3093 100755 --- a/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh +++ b/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh @@ -45,20 +45,6 @@ export AZCOPY_JOB_PLAN_LOCATION="$(pwd)/azcopy-job-plan-files/" mkdir -p "${AZCOPY_LOG_LOCATION}" mkdir -p "${AZCOPY_JOB_PLAN_LOCATION}" -if [ "${ENVIRONMENT,,}" = "tme" ]; then - # If environment is TME, we use a staging container in order to later copy the blob to an immutable container. - DESTINATION_STORAGE_CONTAINER=${CLASSIC_BLOB_STAGING} - STAGING_CONTAINER_EXISTS=$(az storage container exists --account-name ${STORAGE_ACCOUNT_NAME} --name $VHD_STAGING_CONTAINER_NAME --auth-mode login | jq -r '.exists') - if [ "${STAGING_CONTAINER_EXISTS,,}" = "false" ]; then - echo "Creating staging container $VHD_STAGING_CONTAINER_NAME in storage account $STORAGE_ACCOUNT_NAME" - az storage container create --account-name "$STORAGE_ACCOUNT_NAME" --name "$VHD_STAGING_CONTAINER_NAME" --auth-mode login || exit 1 - else - echo "Staging container $VHD_STAGING_CONTAINER_NAME already exists in storage account $STORAGE_ACCOUNT_NAME" - fi -else - DESTINATION_STORAGE_CONTAINER=${CLASSIC_BLOB} -fi - echo "Uploading ${OUT_DIR}/${CONFIG}.vhd to ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" if ! azcopy copy "${OUT_DIR}/${CONFIG}.vhd" "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --recursive=true; then azExitCode=$? @@ -83,15 +69,6 @@ fi echo "Uploaded ${OUT_DIR}/${CONFIG}.vhd to ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" -if [ "${ENVIRONMENT,,}" = "tme" ] && [ "${GENERATE_PUBLISHING_INFO,,}" = "true" ]; then - echo "Copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" - az storage blob copy start --account-name "$STORAGE_ACCOUNT_NAME" --destination-blob "${CAPTURED_SIG_VERSION}.vhd" --destination-container "$VHD_CONTAINER_NAME" --source-uri "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --auth-mode login || exit 1 - echo "Successfully copied to immutable container" -else - echo "GENERATE_PUBLISHING_INFO is false or we are in a testing / prod environment, skipping copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" -fi -capture_benchmark "${SCRIPT_NAME}_upload_vhd_to_blob" - GALLERY_RESOURCE_ID=/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP_NAME}/providers/Microsoft.Compute/galleries/${SIG_GALLERY_NAME} SIG_IMAGE_RESOURCE_ID="${GALLERY_RESOURCE_ID}/images/${SIG_IMAGE_NAME}/versions/${CAPTURED_SIG_VERSION}" MANAGED_IMAGE_RESOURCE_ID="/subscriptions/${SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP_NAME}/providers/Microsoft.Compute/images/${IMAGE_NAME}" From 8768bf0d42a983889a1c330d9c5d21f9e1034f64 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Tue, 6 Jan 2026 12:17:56 -0800 Subject: [PATCH 04/22] fix: move logic to yaml script --- .pipelines/templates/.builder-release-template.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 77a156148ad..2d2fcec6fa3 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -333,6 +333,17 @@ steps: env: RESOURCE_GROUP_NAME: $(AZURE_RESOURCE_GROUP_NAME) + - bash: | + if [ "${ENVIRONMENT,,}" = "tme" ] && [ "${GENERATE_PUBLISHING_INFO,,}" = "true" ]; then + echo "Copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" + az storage blob copy start --account-name "$STORAGE_ACCOUNT_NAME" --destination-blob "${CAPTURED_SIG_VERSION}.vhd" --destination-container "$VHD_CONTAINER_NAME" --source-uri "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --auth-mode login || exit 1 + echo "Successfully copied to immutable container" + else + echo "GENERATE_PUBLISHING_INFO is false or we are in a testing / prod environment, skipping copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" + fi + condition: always() + displayName: Copy to Immutable Storage Container + - task: DownloadPipelineArtifact@2 displayName: Download Build Performance Program condition: and(succeeded(), eq(variables.ENVIRONMENT, 'tme')) From 661d0bc7ce1e87e5df5429292f43e64b28e8c220 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Tue, 6 Jan 2026 13:02:12 -0800 Subject: [PATCH 05/22] fix --- .pipelines/templates/.builder-release-template.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 2d2fcec6fa3..782d7322e23 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -338,6 +338,8 @@ steps: echo "Copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" az storage blob copy start --account-name "$STORAGE_ACCOUNT_NAME" --destination-blob "${CAPTURED_SIG_VERSION}.vhd" --destination-container "$VHD_CONTAINER_NAME" --source-uri "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --auth-mode login || exit 1 echo "Successfully copied to immutable container" + # Remove old VHD from staging container after copy to immutable container is complete + azcopy remove "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --recursive=true else echo "GENERATE_PUBLISHING_INFO is false or we are in a testing / prod environment, skipping copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" fi From a44c90a842962f8b2b299284da60a115a2a21dd8 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Tue, 6 Jan 2026 13:25:07 -0800 Subject: [PATCH 06/22] fix --- .../templates/.builder-release-template.yaml | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 782d7322e23..9d33fc77d16 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -333,17 +333,27 @@ steps: env: RESOURCE_GROUP_NAME: $(AZURE_RESOURCE_GROUP_NAME) - - bash: | - if [ "${ENVIRONMENT,,}" = "tme" ] && [ "${GENERATE_PUBLISHING_INFO,,}" = "true" ]; then - echo "Copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" - az storage blob copy start --account-name "$STORAGE_ACCOUNT_NAME" --destination-blob "${CAPTURED_SIG_VERSION}.vhd" --destination-container "$VHD_CONTAINER_NAME" --source-uri "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --auth-mode login || exit 1 - echo "Successfully copied to immutable container" - # Remove old VHD from staging container after copy to immutable container is complete - azcopy remove "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --recursive=true - else - echo "GENERATE_PUBLISHING_INFO is false or we are in a testing / prod environment, skipping copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" - fi - condition: always() + - task: AzureCLI@2 + inputs: + azureSubscription: $(VHD_ARM_SERVICE_CONNECTION) + scriptType: bash + scriptLocation: inlineScript + inlineScript: | + echo "Copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" + az storage blob copy start --account-name "$STORAGE_ACCOUNT_NAME" --destination-blob "${CAPTURED_SIG_VERSION}.vhd" --destination-container "$VHD_CONTAINER_NAME" --source-uri "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --auth-mode login || exit 1 + echo "Successfully copied to immutable container" + # Remove old VHD from staging container after copy to immutable container is complete + azcopy remove "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --recursive=true + condition: | + or( + and( + succeeded(), + eq(variables.GENERATE_PUBLISHING_INFO, 'True'), + eq(variables.RUN_PREFETCH_OPTIMIZATION, 'False'), + eq(variables.ENVIRONMENT, 'tme') + ), + eq(variables.BUILDER, 'imagecustomizer') + ) displayName: Copy to Immutable Storage Container - task: DownloadPipelineArtifact@2 From 863967d0f2e748b978e7b6dbad7ffa1fff611dd8 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Wed, 7 Jan 2026 07:30:43 -0800 Subject: [PATCH 07/22] fix --- .pipelines/templates/.builder-release-template.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 9d33fc77d16..8286b3ed175 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -340,6 +340,8 @@ steps: scriptLocation: inlineScript inlineScript: | echo "Copying ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd to immutable storage container" + export AZCOPY_AUTO_LOGIN_TYPE="AZCLI" + export AZCOPY_CONCURRENCY_VALUE="AUTO" az storage blob copy start --account-name "$STORAGE_ACCOUNT_NAME" --destination-blob "${CAPTURED_SIG_VERSION}.vhd" --destination-container "$VHD_CONTAINER_NAME" --source-uri "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --auth-mode login || exit 1 echo "Successfully copied to immutable container" # Remove old VHD from staging container after copy to immutable container is complete From 389b52ff3cc0c795fd826b8c065bb14cf0776c69 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Wed, 7 Jan 2026 07:55:34 -0800 Subject: [PATCH 08/22] chore: remove unnecessary vars --- .pipelines/templates/.builder-release-template.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 8286b3ed175..6a38fea5ff3 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -190,9 +190,6 @@ steps: env: RESOURCE_GROUP_NAME: $(AZURE_RESOURCE_GROUP_NAME) GENERATE_PUBLISHING_INFO: $(GENERATE_PUBLISHING_INFO) - CLASSIC_BLOB_STAGING: $(CLASSIC_BLOB_STAGING) - VHD_CONTAINER_NAME: $(VHD_CONTAINER_NAME) - VHD_STAGING_CONTAINER_NAME: $(VHD_STAGING_CONTAINER_NAME) - task: AzureCLI@2 inputs: From 7f373d14d44452307d28a558534435d3b9747a2f Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Wed, 7 Jan 2026 07:56:13 -0800 Subject: [PATCH 09/22] fix --- .../imagecustomizer/scripts/publish-imagecustomizer-image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh b/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh index b63d33c3093..aecf382a505 100755 --- a/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh +++ b/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh @@ -103,7 +103,7 @@ az sig image-version create \ --target-regions ${TARGET_REGIONS} capture_benchmark "${SCRIPT_NAME}_create_sig_image_version" -if [ "${ENVIRONMENT,,}" = "tme" ] || [ "${GENERATE_PUBLISHING_INFO,,}" = "false" ]; then +if [ "${ENVIRONMENT,,}" = "tme" ] && [ "${GENERATE_PUBLISHING_INFO,,}" = "false" ]; then azcopy remove "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --recursive=true fi From f4c6d1663e49620ed071160fb4956342a930e4f9 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Wed, 7 Jan 2026 08:00:46 -0800 Subject: [PATCH 10/22] fix --- .../packer/convert-sig-to-classic-storage-account-blob.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh b/vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh index d0d284e8f0f..a4afd315e63 100755 --- a/vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh +++ b/vhdbuilder/packer/convert-sig-to-classic-storage-account-blob.sh @@ -129,7 +129,7 @@ if [ "$sas" = "None" ]; then fi capture_benchmark "${SCRIPT_NAME}_grant_access_to_disk" -echo "Uploading $disk_resource_id to ${CLASSIC_BLOB}/${CAPTURED_SIG_VERSION}.vhd" +echo "Uploading $disk_resource_id to ${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" echo "Setting azcopy environment variables with pool identity: $AZURE_MSI_RESOURCE_STRING" export AZCOPY_AUTO_LOGIN_TYPE="AZCLI" From 503a432995fb422d20c4eec096d4456be84883b3 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Wed, 7 Jan 2026 08:29:17 -0800 Subject: [PATCH 11/22] fix --- .pipelines/templates/.builder-release-template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 6a38fea5ff3..a9599e75e3b 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -126,7 +126,7 @@ steps: BUILD_DEFINITION_NAME: $(Build.DefinitionName) - bash: | - if [ "${ENVIRONMENT,,}" = "tme" ] && [ "${GENERATE_PUBLISHING_INFO,,}" = "true" ] && [ ${RUN_PREFETCH_OPTIMIZATION,,} = "false" ] || [ ${BUILDER} = "imagecustomizer" ]; then + if [ "${ENVIRONMENT,,}" = "tme" ] && [ "${GENERATE_PUBLISHING_INFO,,}" = "true" ] && [ ${RUN_PREFETCH_OPTIMIZATION,,} = "false" ] || [ ${BUILDER,,} = "imagecustomizer" ]; then DESTINATION_STORAGE_CONTAINER=${CLASSIC_BLOB_STAGING} STAGING_CONTAINER_EXISTS=$(az storage container exists --account-name ${STORAGE_ACCOUNT_NAME} --name $VHD_STAGING_CONTAINER_NAME --auth-mode login | jq -r '.exists') if [ "${STAGING_CONTAINER_EXISTS,,}" = "false" ]; then From 666e8155dcbbc3511c2077a478c3063210e5f9e2 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Thu, 8 Jan 2026 13:57:59 -0800 Subject: [PATCH 12/22] fix --- .../templates/.builder-release-template.yaml | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index a9599e75e3b..836f2c07d1b 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -125,23 +125,6 @@ steps: BUILD_ID: $(Build.BuildId) BUILD_DEFINITION_NAME: $(Build.DefinitionName) - - bash: | - if [ "${ENVIRONMENT,,}" = "tme" ] && [ "${GENERATE_PUBLISHING_INFO,,}" = "true" ] && [ ${RUN_PREFETCH_OPTIMIZATION,,} = "false" ] || [ ${BUILDER,,} = "imagecustomizer" ]; then - DESTINATION_STORAGE_CONTAINER=${CLASSIC_BLOB_STAGING} - STAGING_CONTAINER_EXISTS=$(az storage container exists --account-name ${STORAGE_ACCOUNT_NAME} --name $VHD_STAGING_CONTAINER_NAME --auth-mode login | jq -r '.exists') - if [ "${STAGING_CONTAINER_EXISTS,,}" = "false" ]; then - echo "Creating staging container $VHD_STAGING_CONTAINER_NAME in storage account $STORAGE_ACCOUNT_NAME" - az storage container create --account-name "$STORAGE_ACCOUNT_NAME" --name "$VHD_STAGING_CONTAINER_NAME" --auth-mode login || exit 1 - else - echo "Staging container $VHD_STAGING_CONTAINER_NAME already exists in storage account $STORAGE_ACCOUNT_NAME" - fi - else - DESTINATION_STORAGE_CONTAINER=${CLASSIC_BLOB} - fi - echo "##vso[task.setvariable variable=DESTINATION_STORAGE_CONTAINER]${DESTINATION_STORAGE_CONTAINER}" - condition: always() - displayName: Set Destination Storage Container - - bash: | PACKER_VNET_RESOURCE_GROUP_NAME="$(cat vhdbuilder/packer/settings.json | grep "vnet_resource_group_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ PACKER_VNET_NAME="$(cat vhdbuilder/packer/settings.json | grep "vnet_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ @@ -149,6 +132,7 @@ steps: SIG_IMAGE_NAME="$(cat vhdbuilder/packer/settings.json | grep "sig_image_name" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ BUILD_LOCATION="$(cat vhdbuilder/packer/settings.json | grep "location" | awk -F':' '{print $2}' | awk -F'"' '{print $2}')" && \ ARTIFACT_ID=$(date +%s) && \ + echo "##vso[task.setvariable variable=DESTINATION_STORAGE_CONTAINER]${CLASSIC_BLOB}" && \ echo "##vso[task.setvariable variable=ARTIFACT_ID]${ARTIFACT_ID}" && \ echo "##vso[task.setvariable variable=PACKER_BUILD_LOCATION]${BUILD_LOCATION}" && \ echo "##vso[task.setvariable variable=PACKER_VNET_RESOURCE_GROUP_NAME]${PACKER_VNET_RESOURCE_GROUP_NAME}" && \ @@ -177,6 +161,33 @@ steps: condition: always() displayName: Set Post-Build Variables + - task: AzureCLI@2 + inputs: + azureSubscription: $(VHD_ARM_SERVICE_CONNECTION) + scriptType: bash + scriptLocation: inlineScript + inlineScript: | + DESTINATION_STORAGE_CONTAINER=${CLASSIC_BLOB_STAGING} + STAGING_CONTAINER_EXISTS=$(az storage container exists --account-name ${STORAGE_ACCOUNT_NAME} --name $VHD_STAGING_CONTAINER_NAME --auth-mode login | jq -r '.exists') + if [ "${STAGING_CONTAINER_EXISTS,,}" = "false" ]; then + echo "Creating staging container $VHD_STAGING_CONTAINER_NAME in storage account $STORAGE_ACCOUNT_NAME" + az storage container create --account-name "$STORAGE_ACCOUNT_NAME" --name "$VHD_STAGING_CONTAINER_NAME" --auth-mode login || exit 1 + else + echo "Staging container $VHD_STAGING_CONTAINER_NAME already exists in storage account $STORAGE_ACCOUNT_NAME" + fi + echo "DESTINATION_STORAGE_CONTAINER is set to ${DESTINATION_STORAGE_CONTAINER}" + condition: | + or( + and( + succeeded(), + eq(variables.GENERATE_PUBLISHING_INFO, 'True'), + eq(variables.RUN_PREFETCH_OPTIMIZATION, 'False'), + eq(variables.ENVIRONMENT, 'tme') + ), + eq(variables.BUILDER, 'imagecustomizer') + ) + displayName: Set Destination Storage Container if Prefectch Optimization is Disabled + - task: AzureCLI@2 inputs: azureSubscription: $(VHD_ARM_SERVICE_CONNECTION) From 743cd521eef139208f1244c0393a34d77d99ccda Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Fri, 9 Jan 2026 08:19:41 -0800 Subject: [PATCH 13/22] fix --- .pipelines/templates/.builder-release-template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 836f2c07d1b..28e376c6916 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -186,7 +186,7 @@ steps: ), eq(variables.BUILDER, 'imagecustomizer') ) - displayName: Set Destination Storage Container if Prefectch Optimization is Disabled + displayName: Set Destination Storage Container - task: AzureCLI@2 inputs: From 9fe4ee8d3840546aa0846c4b2ffdec2c57ddeabf Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Fri, 9 Jan 2026 09:47:33 -0800 Subject: [PATCH 14/22] fix --- .pipelines/templates/.builder-release-template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 28e376c6916..f5abbac61a2 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -167,7 +167,7 @@ steps: scriptType: bash scriptLocation: inlineScript inlineScript: | - DESTINATION_STORAGE_CONTAINER=${CLASSIC_BLOB_STAGING} + echo "##vso[task.setvariable variable=DESTINATION_STORAGE_CONTAINER]${CLASSIC_BLOB_STAGING}" && \ STAGING_CONTAINER_EXISTS=$(az storage container exists --account-name ${STORAGE_ACCOUNT_NAME} --name $VHD_STAGING_CONTAINER_NAME --auth-mode login | jq -r '.exists') if [ "${STAGING_CONTAINER_EXISTS,,}" = "false" ]; then echo "Creating staging container $VHD_STAGING_CONTAINER_NAME in storage account $STORAGE_ACCOUNT_NAME" From 53a04236f5bf1144399ae492fc97cb192a63425f Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Fri, 9 Jan 2026 10:22:14 -0800 Subject: [PATCH 15/22] fix: wrong var, pipeline vars are not ready until next step --- .pipelines/templates/.builder-release-template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index f5abbac61a2..e59f880c4bb 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -175,7 +175,7 @@ steps: else echo "Staging container $VHD_STAGING_CONTAINER_NAME already exists in storage account $STORAGE_ACCOUNT_NAME" fi - echo "DESTINATION_STORAGE_CONTAINER is set to ${DESTINATION_STORAGE_CONTAINER}" + echo "DESTINATION_STORAGE_CONTAINER is set to ${CLASSIC_BLOB_STAGING}" condition: | or( and( From 2063591e16e85e57ae34be7a657c42249bbdb42c Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Mon, 12 Jan 2026 07:46:05 -0800 Subject: [PATCH 16/22] chore: clarify step name --- .pipelines/templates/.builder-release-template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index e59f880c4bb..3165ee37434 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -186,7 +186,7 @@ steps: ), eq(variables.BUILDER, 'imagecustomizer') ) - displayName: Set Destination Storage Container + displayName: Set Destination Storage Container to Staging - task: AzureCLI@2 inputs: From b5ab7b4b04cc4ee98b0a99209248e65120ce9196 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Mon, 12 Jan 2026 07:47:38 -0800 Subject: [PATCH 17/22] fix --- .pipelines/templates/.builder-release-template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 3165ee37434..69241b16f9b 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -184,7 +184,7 @@ steps: eq(variables.RUN_PREFETCH_OPTIMIZATION, 'False'), eq(variables.ENVIRONMENT, 'tme') ), - eq(variables.BUILDER, 'imagecustomizer') + eq(variables.BUILDER, 'imagecustomizer') ) displayName: Set Destination Storage Container to Staging From a5b2296dd16bb7734633190d0c84938256a06196 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Mon, 12 Jan 2026 07:49:01 -0800 Subject: [PATCH 18/22] fix: indent --- .pipelines/templates/.builder-release-template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 69241b16f9b..faf002bebdb 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -362,7 +362,7 @@ steps: eq(variables.RUN_PREFETCH_OPTIMIZATION, 'False'), eq(variables.ENVIRONMENT, 'tme') ), - eq(variables.BUILDER, 'imagecustomizer') + eq(variables.BUILDER, 'imagecustomizer') ) displayName: Copy to Immutable Storage Container From a95482c4053bad5d9ad2a980243f9255010ac778 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Mon, 12 Jan 2026 10:31:36 -0800 Subject: [PATCH 19/22] fix --- .pipelines/templates/.builder-release-template.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index faf002bebdb..6c8b163f981 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -184,7 +184,9 @@ steps: eq(variables.RUN_PREFETCH_OPTIMIZATION, 'False'), eq(variables.ENVIRONMENT, 'tme') ), - eq(variables.BUILDER, 'imagecustomizer') + and( + eq(variables.BUILDER, 'imagecustomizer'), + eq(variables.ENVIRONMENT, 'tme') ) displayName: Set Destination Storage Container to Staging @@ -362,7 +364,9 @@ steps: eq(variables.RUN_PREFETCH_OPTIMIZATION, 'False'), eq(variables.ENVIRONMENT, 'tme') ), - eq(variables.BUILDER, 'imagecustomizer') + and( + eq(variables.BUILDER, 'imagecustomizer'), + eq(variables.ENVIRONMENT, 'tme') ) displayName: Copy to Immutable Storage Container From 0de97193a78e052e81e31b04b23183b728998968 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Mon, 12 Jan 2026 10:32:58 -0800 Subject: [PATCH 20/22] fix --- .../imagecustomizer/scripts/publish-imagecustomizer-image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh b/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh index aecf382a505..fcbb14e044d 100755 --- a/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh +++ b/vhdbuilder/packer/imagecustomizer/scripts/publish-imagecustomizer-image.sh @@ -103,7 +103,7 @@ az sig image-version create \ --target-regions ${TARGET_REGIONS} capture_benchmark "${SCRIPT_NAME}_create_sig_image_version" -if [ "${ENVIRONMENT,,}" = "tme" ] && [ "${GENERATE_PUBLISHING_INFO,,}" = "false" ]; then +if [ "${GENERATE_PUBLISHING_INFO,,}" = "false" ]; then azcopy remove "${DESTINATION_STORAGE_CONTAINER}/${CAPTURED_SIG_VERSION}.vhd" --recursive=true fi From 8f77f459c19f4d6fd8023122c1d2a83b9b87f9a5 Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Mon, 12 Jan 2026 10:35:19 -0800 Subject: [PATCH 21/22] fix --- .pipelines/templates/.builder-release-template.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 6c8b163f981..91c92a4377d 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -187,6 +187,7 @@ steps: and( eq(variables.BUILDER, 'imagecustomizer'), eq(variables.ENVIRONMENT, 'tme') + ), ) displayName: Set Destination Storage Container to Staging @@ -367,6 +368,7 @@ steps: and( eq(variables.BUILDER, 'imagecustomizer'), eq(variables.ENVIRONMENT, 'tme') + ), ) displayName: Copy to Immutable Storage Container From 335768dcfe9c75294b7c139bb415e74a759df1ee Mon Sep 17 00:00:00 2001 From: Zachary Bailey Date: Mon, 12 Jan 2026 10:38:49 -0800 Subject: [PATCH 22/22] fix --- .pipelines/templates/.builder-release-template.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pipelines/templates/.builder-release-template.yaml b/.pipelines/templates/.builder-release-template.yaml index 91c92a4377d..d1e876eae83 100644 --- a/.pipelines/templates/.builder-release-template.yaml +++ b/.pipelines/templates/.builder-release-template.yaml @@ -187,7 +187,7 @@ steps: and( eq(variables.BUILDER, 'imagecustomizer'), eq(variables.ENVIRONMENT, 'tme') - ), + ) ) displayName: Set Destination Storage Container to Staging @@ -368,7 +368,7 @@ steps: and( eq(variables.BUILDER, 'imagecustomizer'), eq(variables.ENVIRONMENT, 'tme') - ), + ) ) displayName: Copy to Immutable Storage Container