%3CLINGO-SUB%20id%3D%22lingo-sub-1506722%22%20slang%3D%22en-US%22%3EZero%20to%20Hero%20with%20App%20Service%2C%20Part%203%3A%20Releasing%20to%20Production%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1506722%22%20slang%3D%22en-US%22%3E%3CP%3E%3CEM%3EThis%20is%20the%20third%20article%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fazure.github.io%2FAppService%2Ftags%2F%23zero-to-hero%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EZero%20to%20Hero%20with%20App%20Service%3C%2FA%3E%20series.%20This%20article%20assumes%20you%20have%20already%20completed%20the%20previous%20two%20articles.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20this%20point%2C%20you%20have%20a%20CI%2FCD%20pipeline%20built%20on%20GitHub%20Actions%20that%20deploys%20your%20code%20into%20a%20staging%20slot%20whenever%20a%20commit%20is%20pushed%20to%20the%20main%20branch.%20In%20this%20article%2C%20you%20will%20learn%20how%20to%20release%20your%20new%20build%20to%20your%20production%20traffic%20by%20%3CEM%3Eswapping%3C%2FEM%3E%20the%20production%20and%20staging%20slots.%20You%20will%20also%20learn%20how%20to%20route%20a%20percentage%20of%20your%20production%20traffic%20to%20the%20staging%20environment%20to%20test%20the%20next%20build%20before%20it%20is%20fully%20released.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1301764050%22%20id%3D%22toc-hId--1301764050%22%3ESwap%20the%20slots%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOpen%20the%20Azure%20Portal%20to%20your%20web%20app.%20On%20the%20left%20side%20menu%2C%20select%20%3CSTRONG%3EDeployment%20slots%3C%2FSTRONG%3E.%20This%20will%20open%20a%20new%20blade%20showing%20a%20list%20of%20your%20site%E2%80%99s%20slots.%20You%20will%20see%20a%20%3CSTRONG%3Eproduction%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Estaging%3C%2FSTRONG%3E%20slot.%20Click%20the%20%3CSTRONG%3ESwap%3C%2FSTRONG%3E%20button%20at%20the%20top.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Jason_Freeberg_0-1594145910588.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F203904i3CD67D1E3A7484B3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Jason_Freeberg_0-1594145910588.png%22%20alt%3D%22Jason_Freeberg_0-1594145910588.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%3CSTRONG%3ESwap%3C%2FSTRONG%3E%20button%20will%20open%20a%20context%20menu%20with%20a%20table%20to%20preview%20any%20changes%20configuration%20changes%20that%20will%20occur%20after%20the%20swap.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fconfigure-common%23configure-app-settings%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EApp%20settings%3C%2FA%3E%20are%20key-value%20configurations%20that%20are%20exposed%20to%20your%20app%20as%20environment%20variables.%20A%20future%20article%20will%20cover%20app%20settings%20in%20more%20detail.%20Click%20%3CSTRONG%3Eswap%3C%2FSTRONG%3E%20at%20the%20bottom%20of%20the%20menu%20to%20swap%20the%20slots.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Jason_Freeberg_1-1594145979998.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F203906i3E2F29EDE4DEBB7D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Jason_Freeberg_1-1594145979998.png%22%20alt%3D%22Jason_Freeberg_1-1594145979998.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23000000%22%3EWhen%20the%20operation%20completes%2C%20browse%20to%20the%20production%20site%20and%20you%20should%20see%20the%20sample%20application!%20The%20staging%20slot%20should%20now%20have%20the%20sample%20application%2C%20and%20the%20staging%20slot%20will%20have%20the%20placeholder%20HTML%20page%20with%20help%20text.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CEM%3EYou%20can%20also%20%3C%2FEM%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fdeploy-best-practices%23continuously-deploy-containers%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Euse%20slots%20with%20custom%20containers%3C%2FEM%3E%3C%2FA%3E%3CEM%3E.%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1185748783%22%20id%3D%22toc-hId-1185748783%22%3ECheckpoint%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23000000%22%3EUp%20to%20now%2C%20you%20have%20a%20GitHub%20repository%20that%20will%20trigger%20a%20GitHub%20Action%20workflow%20whenever%20there%20is%20a%20push%20to%20the%20main%20branch.%20The%20workflow%20builds%20and%20deploys%20the%20application%20to%20the%20staging%20slot%20of%20the%20site.%20You%20can%20use%20the%20staging%20site%20to%20validate%20your%20latest%20changes.%20When%20you%E2%80%99re%20ready%2C%20use%20the%20swap%20button%20(or%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcli%2Fazure%2Fwebapp%2Fdeployment%2Fslot%3Fview%3Dazure-cli-latest%23az-webapp-deployment-slot-swap%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ECLI%20command%3C%2FA%3E)%20to%20swap%20the%20slots.%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22Jason_Freeberg_2-1594146011643.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F203907iF618E13C5B2AA940%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Jason_Freeberg_2-1594146011643.png%22%20alt%3D%22Jason_Freeberg_2-1594146011643.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20work%20in%20a%20large%20team%2C%20you%20can%20create%20slots%20for%20testing%2C%20quality%20assurance%2C%20canary%20testing%2C%20A%2FB%20testing%2C%20and%20more.%20Here%20is%20an%20example%20use%20case%20for%20multiple%20slots%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EContinuously%20deploy%20the%20master%20branch%20into%20a%20%E2%80%9Ctesting%E2%80%9D%20slot%20for%20developers%20to%20easily%20validate%20changes%20without%20pulling%20the%20branch%20and%20run%20it%20locally.%3C%2FLI%3E%0A%3CLI%3ESwap%20the%20build%20into%20a%20QA%20slot%20where%20the%20configuration%20more%20closely%20resembles%20the%20production%20slot.%20The%20new%20build%20is%20thoroughly%20tested%20by%20a%20QA%20or%20acceptance%20team.%3C%2FLI%3E%0A%3CLI%3ESwap%20into%20a%20staging%20slot%20where%20the%20build%20is%20tested%20against%20a%20fraction%20of%20the%20production%20traffic.%20The%20configuration%20here%20should%20match%20the%20production%20slot.%3C%2FLI%3E%0A%3CLI%3EFully%20release%20the%20new%20build%20by%20swapping%20into%20the%20production%20slot.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CEM%3EThere%20is%20an%20implicit%20distinction%20between%20deploying%20and%20releasing.%20For%20more%20information%20on%20this%20distinction%2C%20see%20%3C%2FEM%3E%3CA%20href%3D%22https%3A%2F%2Fblog.turbinelabs.io%2Fdeploy-not-equal-release-part-one-4724bc1e726b%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Ethis%20article%3C%2FEM%3E%3C%2FA%3E%3CEM%3E.%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--621705680%22%20id%3D%22toc-hId--621705680%22%3ETesting%20in%20Production%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETesting%20in%20Production%20is%20the%20general%20practice%20of%20utilizing%20production%20traffic%20to%20test%20a%20new%20deployment%20before%20fully%20releasing%20it.%20This%20is%20an%20umbrella%20term%20for%20activities%20such%20as%20traffic%20shadowing%2C%20mirroring%2C%20or%20canarying.%20Traffic%20%3CA%20href%3D%22https%3A%2F%2Fwww.getambassador.io%2Fdocs%2Flatest%2Ftopics%2Fusing%2Fshadowing%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eshadowing%3C%2FA%3E%20and%20mirroring%20are%20interesting%20topics%2C%20but%20they%20are%20outside%20the%20scope%20of%20this%20article.%20The%20remaining%20sections%20will%20explain%20how%20to%20%3CEM%3Ecanary%3C%2FEM%3E%20your%20new%20deployments%20with%20App%20Service%20before%20releasing%20them%20to%20production.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId-68855794%22%20id%3D%22toc-hId-68855794%22%3EConfiguration%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20the%20Azure%20Portal%2C%20go%20to%20the%20%3CSTRONG%3EDeployment%20Slots%3C%2FSTRONG%3E%20menu.%20In%20the%20table%20of%20your%20slots%2C%20you%20will%20see%20a%20column%20for%20%3CSTRONG%3ETraffic%20%25%3C%2FSTRONG%3E.%20By%20default%2C%20all%20your%20traffic%20is%20routed%20to%20the%20production%20slot.%20Try%20setting%20the%20traffic%20percentage%20to%20%3CSTRONG%3E10%25%3C%2FSTRONG%3E%20on%20the%20staging%20slot.%20Then%20click%20%3CSTRONG%3ESave.%20%3C%2FSTRONG%3EWith%20that%20simple%20change%2C%20a%20tenth%20of%20your%20production%20traffic%20will%20now%20go%20to%20the%20new%20build!%20This%20practice%20is%20known%20as%20a%20%E2%80%9Ccanary%20deployment%E2%80%9D%20or%20%E2%80%9Ccanarying%20a%20build%E2%80%9D.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CIFRAME%20src%3D%22https%3A%2F%2Fchannel9.msdn.com%2FShows%2FAzure-Friday%2FTesting-in-production-with-Azure-App-Service%2Fplayer%22%20width%3D%22960%22%20height%3D%22540%22%20frameborder%3D%220%22%20allowfullscreen%3D%22allowfullscreen%22%20title%3D%22Testing%20in%20production%20with%20Azure%20App%20Service%20-%20Microsoft%20Channel%209%20Video%22%3E%3C%2FIFRAME%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CEM%3EThe%20term%20%E2%80%9Ccanary%20deployment%E2%80%9D%20originates%20from%20%3C%2FEM%3E%3CA%20href%3D%22https%3A%2F%2Fen.wiktionary.org%2Fwiki%2Fcanary_in_a_coal_mine%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CEM%3Ethe%20%E2%80%9Ccanary%20in%20a%20coal%20mine%E2%80%9D%20idiom%3C%2FEM%3E%3C%2FA%3E%3CEM%3E.%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1738598669%22%20id%3D%22toc-hId--1738598669%22%3ETagging%20telemetry%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20that%20some%20of%20your%20production%20%3CFONT%20color%3D%22%23000000%22%3Etraffic%3C%2FFONT%3E%20is%20routed%20to%20the%20new%20build%2C%20it%20is%20prudent%20to%20monitor%20the%20success%20of%20your%20deployment%20to%20catch%20errors%2C%20slow%20code%20paths%2C%20or%20other%20unforeseen%20issues.%20If%20you%20are%20using%20an%20application%20monitoring%20tool%20like%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fapp%2Fapp-insights-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EApplication%20Insights%3C%2FA%3E%2C%20Splunk%2C%20or%20Dynatrace%2C%20you%20will%20want%20to%20tag%20the%20metrics%20and%20logs%20coming%20from%20your%20staging%20slot%20so%20you%20can%20appropriately%20split%20the%20data%20in%20your%20reports%20and%20dashboards.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20your%20client-side%20code%2C%20the%20slot%20will%20expose%20a%20cookie%2C%20x-ms-routing-name%2C%20%26nbsp%3Bwith%20the%20slot%E2%80%99s%20name.%20You%20can%20retrieve%20this%20cookie%20and%20tag%20any%20outgoing%20metrics%20or%20logs.%20In%20your%20monitoring%20service%E2%80%99s%20dashboard%2C%20you%20can%20filter%20or%20split%20the%20data%20on%20this%20tag.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20server-side%20code%2C%20the%20slot%20will%20expose%20an%20environment%20variable%2C%20SITE_HOSTNAME%2C%20which%20contains%20the%20hostname%20and%20slot%20name.%20Much%20like%20the%20client-side%20cookie%2C%20you%20can%20grab%20the%20value%20of%20the%20environment%20variable%20and%20tag%20your%20logs%20or%20metrics.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23808080%22%3E%3CEM%3EYou%20can%20manually%20route%20clients%20to%20a%20slot%20using%20the%20%3C%2FEM%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fdeploy-staging-slots%23route-production-traffic-manually%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSTRONG%3E%3CEM%3Ex-ms-routing-name%3C%2FEM%3E%3C%2FSTRONG%3E%3CEM%3E%20query%20parameter%3C%2FEM%3E%3C%2FA%3E%3CEM%3E.%3C%2FEM%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1749101773%22%20id%3D%22toc-hId--1749101773%22%3ESummary%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3ECongratulations!%3C%2FEM%3E%20Now%20you%20know%20how%20to%20release%20your%20latest%20deployments.%20You%20can%20also%20route%20a%20percentage%20of%20your%20production%20traffic%20to%20canary%20test%20the%20new%20build%20before%20%3CSTRONG%3Efully%3C%2FSTRONG%3E%20releasing%20it.%20The%20next%20articles%20will%20cover%20certificates%2C%20domains%2C%20network%20security%2C%20and%20advanced%20configuration%E2%80%A6%20%3CEM%3Eso%20stay%20tuned%20for%20more!%3C%2FEM%3E%3C%2FP%3E%0A%3CH3%20id%3D%22toc-hId--1058540299%22%20id%3D%22toc-hId--1058540299%22%3E%26nbsp%3B%3C%2FH3%3E%0A%3CH3%20id%3D%22toc-hId-1428972534%22%20id%3D%22toc-hId-1428972534%22%3EHelpful%20Links%3C%2FH3%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fmedium.com%2F%40copyconstruct%2Ftesting-in-production-the-safe-way-18ca102d0ef1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3ETesting%20in%20Production%2C%20the%20safe%20way%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fapp-service%2Fdeploy-best-practices%23use-deployment-slots%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EBest%20Practices%20for%20App%20Service%20deployment%20slots%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1506722%22%20slang%3D%22en-US%22%3E%3CP%3ELearn%20how%20to%20release%20your%20new%20build%20to%20your%20production%20traffic%20by%20%3CEM%3Eswapping%3C%2FEM%3E%20the%20production%20and%20staging%20slots.%20Also%2C%20learn%20how%20to%20route%20a%20percentage%20of%20your%20production%20traffic%20to%20the%20staging%20environment%20to%20test%20the%20next%20build%20before%20it%20is%20fully%20released.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1506722%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3E.NET%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20App%20Service%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EJava%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ENode.js%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWeb%20Apps%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

This is the third article in the Zero to Hero with App Service series. This article assumes you have already completed the previous two articles.

 

At this point, you have a CI/CD pipeline built on GitHub Actions that deploys your code into a staging slot whenever a commit is pushed to the main branch. In this article, you will learn how to release your new build to your production traffic by swapping the production and staging slots. You will also learn how to route a percentage of your production traffic to the staging environment to test the next build before it is fully released.

 

Swap the slots

 

Open the Azure Portal to your web app. On the left side menu, select Deployment slots. This will open a new blade showing a list of your site’s slots. You will see a production and staging slot. Click the Swap button at the top.

 

Jason_Freeberg_0-1594145910588.png

 

The Swap button will open a context menu with a table to preview any changes configuration changes that will occur after the swap. App settings are key-value configurations that are exposed to your app as environment variables. A future article will cover app settings in more detail. Click swap at the bottom of the menu to swap the slots.

 

 

Jason_Freeberg_1-1594145979998.png

 

When the operation completes, browse to the production site and you should see the sample application! The staging slot should now have the sample application, and the staging slot will have the placeholder HTML page with help text.

 

You can also use slots with custom containers.

 

Checkpoint

 

Up to now, you have a GitHub repository that will trigger a GitHub Action workflow whenever there is a push to the main branch. The workflow builds and deploys the application to the staging slot of the site. You can use the staging site to validate your latest changes. When you’re ready, use the swap button (or CLI command) to swap the slots.

 

Jason_Freeberg_2-1594146011643.png

 

 

If you work in a large team, you can create slots for testing, quality assurance, canary testing, A/B testing, and more. Here is an example use case for multiple slots:

 

  1. Continuously deploy the master branch into a “testing” slot for developers to easily validate changes without pulling the branch and run it locally.
  2. Swap the build into a QA slot where the configuration more closely resembles the production slot. The new build is thoroughly tested by a QA or acceptance team.
  3. Swap into a staging slot where the build is tested against a fraction of the production traffic. The configuration here should match the production slot.
  4. Fully release the new build by swapping into the production slot.

 

There is an implicit distinction between deploying and releasing. For more information on this distinction, see this article.

 

Testing in Production

 

Testing in Production is the general practice of utilizing production traffic to test a new deployment before fully releasing it. This is an umbrella term for activities such as traffic shadowing, mirroring, or canarying. Traffic shadowing and mirroring are interesting topics, but they are outside the scope of this article. The remaining sections will explain how to canary your new deployments with App Service before releasing them to production.

 

Configuration

 

In the Azure Portal, go to the Deployment Slots menu. In the table of your slots, you will see a column for Traffic %. By default, all your traffic is routed to the production slot. Try setting the traffic percentage to 10% on the staging slot. Then click Save. With that simple change, a tenth of your production traffic will now go to the new build! This practice is known as a “canary deployment” or “canarying a build”.

 

The term “canary deployment” originates from the “canary in a coal mine” idiom.

 

Tagging telemetry

 

Now that some of your production traffic is routed to the new build, it is prudent to monitor the success of your deployment to catch errors, slow code paths, or other unforeseen issues. If you are using an application monitoring tool like Application Insights, Splunk, or Dynatrace, you will want to tag the metrics and logs coming from your staging slot so you can appropriately split the data in your reports and dashboards.

 

For your client-side code, the slot will expose a cookie, x-ms-routing-name,  with the slot’s name. You can retrieve this cookie and tag any outgoing metrics or logs. In your monitoring service’s dashboard, you can filter or split the data on this tag.

 

For server-side code, the slot will expose an environment variable, SITE_HOSTNAME, which contains the hostname and slot name. Much like the client-side cookie, you can grab the value of the environment variable and tag your logs or metrics.

 

You can manually route clients to a slot using the x-ms-routing-name query parameter.

 

Summary

 

Congratulations! Now you know how to release your latest deployments. You can also route a percentage of your production traffic to canary test the new build before fully releasing it. The next articles will cover certificates, domains, network security, and advanced configuration… so stay tuned for more!

 

Helpful Links