Skip to content

Commit 1d1fee4

Browse files
author
Fernando Antivero
authored
improve atomic deployments (#55)
- use paths for versioning - use major.minor.patch-commits_since_version_source - remove purge instructions as it is no longer required - add instruction to switch between versions Pros 1. 100% atomic deployments. Content won’t be available till the big-bang moment in which the origin’s path gets updated. Purge or content expiration doesn’t affect what Azure CDN serves leaving you in full control when new content starts being served. 2. better content organization and visualization 3. don't have to wait for cache to expire before Azure CDN begins to serve a new version and it doesn’t require to execute a purge action (cache invalidation) 4. enhanceed control over managing the content that Azure CDN serves - it is possible to easily clean up the container enabling use cases like history max level (e.g. keep last 3 most recent versions) - it is just matter of target another container folder to rollback to a previous version - it allows SxS versions enabling more sophisticated use cases like previewing new website versions before they are live and many other scenarios (support older versions, variations, etc.) Cons 1. if some content was being downloaded and newer version just kicked-in, user might face some 404. 2. more space might be required, same content is now duplicated on every folder solved: #114210
1 parent ed700cc commit 1d1fee4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/ClientApp/azure-pipelines.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ stages:
3939
4040
- script: |
4141
cd $(Build.SourcesDirectory)
42-
echo $(docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.0.1-linux-netcoreapp2.1 /repo | grep -oP '(?<="MajorMinorPatch":")[^"]*') > src/ClientApp/public/version.txt
42+
echo $(docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.0.1-linux-netcoreapp2.1 /repo) > .gitversion
43+
echo $(cat .gitversion | grep -oP '(?<="MajorMinorPatch":")[^"]*') > src/ClientApp/public/version.txt
44+
echo $(cat .gitversion | grep -oP '(?<="FullSemVer":")[^"]*' | sed -e "s/\+/-/g") > src/ClientApp/public/semver.txt
4345
displayName: 'bump version'
4446
4547
- task: PublishBuildArtifacts@1
@@ -61,6 +63,7 @@ stages:
6163
steps:
6264
- script: |
6365
echo '##vso[task.setvariable variable=releaseVersion]'$(cat "$(Pipeline.Workspace)/drop/version.txt")
66+
echo '##vso[task.setvariable variable=releaseSemVer]'$(cat "$(Pipeline.Workspace)/drop/semver.txt")
6467
displayName: 'set release version'
6568
name: setVarReleaseVersion
6669
@@ -75,15 +78,17 @@ stages:
7578

7679
- script: |
7780
az login --service-principal -u $(azureArmClientId) -p $(azureArmClientSecret) --tenant $(azureArmTenantId)
78-
az storage blob upload-batch -s "$(Pipeline.Workspace)/drop" --destination \$web --account-name $(azureStorageAccountName)
79-
az cdn endpoint purge --resource-group $(azureResourceGroup) --profile-name $(azureCdnName) --name $(azureCdnName) --content-paths '/' '/index.html' '/404.html' '/version.txt'
81+
# upload content to container versioned folder
82+
az storage blob upload-batch -s "$(Pipeline.Workspace)/drop" --destination "\$web\$(releaseSemVer)" --account-name $(azureStorageAccountName)
83+
# target new version
84+
az cdn endpoint update --resource-group $(azureResourceGroup) --profile-name $(azureCdnName) --name $(azureCdnName) --origin-path '/$(releaseSemVer)'
8085
AZURE_CDN_ENDPOINT_HOSTNAME=$(az cdn endpoint show --resource-group $(azureResourceGroup) --name $(azureCdnName) --profile-name $(azureCdnName) --query hostName -o tsv)
8186
echo "Azure CDN endpooint host ${AZURE_CDN_ENDPOINT_HOSTNAME}"
8287
echo '##vso[task.setvariable variable=azureCndEndpointHost]'$AZURE_CDN_ENDPOINT_HOSTNAME
8388
displayName: 'upload to Azure Storage static website hosting and purge Azure CDN endpoint'
8489
8590
- script: |
86-
liveVersion=$(curl --fail --silent "https://$(azureCndEndpointHost)/version.txt")
87-
[[ $liveVersion == $(releaseVersion) ]] && echo -e "\033[1;32m## [Passed] website validation Ok: $liveVersion is live now\033[0m" || >&2 echo -e "\033[0;31m## [Fail] website validation Fail: expected $(releaseVersion) - actual $liveVersion\033[0m"
91+
liveVersion=$(curl --fail --silent "https://$(azureCndEndpointHost)/semver.txt")
92+
[[ $liveVersion == $(releaseSemVer) ]] && echo -e "\033[1;32m## [Passed] website validation Ok: $liveVersion is live now\033[0m" || >&2 echo -e "\033[0;31m## [Fail] website validation Fail: expected $(releaseSemVer) - actual $liveVersion\033[0m"
8893
displayName: 'validate website version'
8994
failOnStderr: true

0 commit comments

Comments
 (0)