%3CLINGO-SUB%20id%3D%22lingo-sub-1423443%22%20slang%3D%22en-US%22%3ERe%3A%20Desired%20State%20Configuration%20Extension%20and%20the%20Replica%20Domain%20Controller%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1423443%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F606731%22%20target%3D%22_blank%22%3E%40shankuehn%3C%2FA%3E%26nbsp%3Bthanks%20for%20your%20article.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20two%20links%20have%20malformed%20URL.%3CA%20href%3D%22http%3A%2F%2F%2520https%2F%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3C%2FA%3E%3C%2FP%3E%3CPRE%3Ehttp%3A%2F%2F%2520https%2F%2F%3C%2FPRE%3E%3CP%3E%3CA%20href%3D%22http%3A%2F%2F%2520https%2F%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1390241%22%20slang%3D%22en-US%22%3EDesired%20State%20Configuration%20Extension%20and%20the%20Replica%20Domain%20Controller%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1390241%22%20slang%3D%22en-US%22%3E%3CP%3EBy%20now%2C%20you%20have%20probably%20examined%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fsbkuehn%2FreplicaDcs%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Emy%20code%3C%2FA%3E%20(if%20not%2C%20please%20click%20the%20link).%20If%20you%20are%20familiar%20with%20ARM%20Templates%2C%20the%20code%20should%20seem%20relatively%20straightforward.%20There%20is%20one%20piece%20that%20may%20seem%20foreign%20though%3A%20the%20Desired%20State%20Configuration%20(or%20DSC)%20extension.%20I%20wanted%20to%20take%20some%20time%20out%20and%20unpack%20the%20DSC%20extension%20within%20your%20ARM%20Template%20configuration.%20From%20there%2C%20the%20last%20post%20will%20surround%20the%20DSC%20script%20plus%20how%20to%20troubleshoot%20if%20something%20does%20not%20work%20right%20(these%20topics%20are%20ever%20so%20slightly%20mysterious%20at%20times).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%20off%2C%20let%20us%20dig%20into%20what%20DSC%20is%20related%20to%20infrastructure%20as%20code.%20The%20management%20and%20maintenance%20of%20servers%20becomes%20difficult%20and%20challenging%20as%20time%20evolves%20plus%20configurations%20change.%20In%20the%20sysadmin%20world%2C%20we%20tend%20to%20end%20up%20with%20a%20plethora%20of%20scripts%20to%20manage%20a%20server%20and%20usually%20those%20scripts%20live%20on%20some%20sort%20of%20utils%20server%20or%20UNC%20share.%20With%20the%20cloud%2C%20that%20legacy%20practice%20just%20does%20not%20scale%20(unfortunately).%20With%20cloud%2C%20we%20need%20a%20better%20way%20to%20automate%20a%20task%20(and%20maybe%20even%20a%20series%20of%20tasks)%20or%20a%20configuration%20state%20to%20prevent%20configuration%20drift%20among%20servers.%20DSC%20is%20a%20declarative%20way%20of%20leaning%20on%20PowerShell%20scripts%2C%20where%20you%20define%20and%20configure%20instances%20of%20resources.%20Upon%20running%20configurations%2C%20DSC%20ensures%20the%20configurations%20match%20up%20with%20a%20predefined%20state%20all%20servers%20should%20hold.%20These%20configurations%20are%20also%20idempotent%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fscripting%2Fdsc%2Fmanaging-nodes%2Fmetaconfig%3Fview%3Dpowershell-7%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EThe%20Local%20Configuration%20Manager%20(LCM)%3C%2FA%3E%20continues%20to%20ensure%20that%20machines%20are%20configured%20in%20whatever%20state%20the%20configuration%20declares.%20Typically%2C%20these%20configurations%20exist%20on%20some%20sort%20of%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fscripting%2Fdsc%2Fpull-server%2Fpullserver%3Fview%3Dpowershell-7%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Epull%20server%3C%2FA%3E.%20The%20pull%20server%20is%20an%20automation%20server%20that%20allows%20all%20configurations%20to%20be%20maintained%20on%20many%20servers%20across%20a%20network.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESeems%20simple%20as%20a%20concept%20and%20a%20powerful%20reality%20that%20all%20sysadmins%20should%20be%20adopting%2C%20right%3F%20Right.%20After%20reading%20through%20these%20descriptions%2C%20you%20may%20be%20wondering%20how%20DSC%20works%20with%20my%20ARM%20Template%20and%20that%20is%20ever%20so%20slightly%20different.%20I%20want%20to%20shed%20some%20light%2C%20as%20I%20am%20not%20deploying%20a%20pull%20server%2C%20but%20I%20am%20using%20a%20DSC%20script%20%2B%20a%20DSC%20extension%20to%20tell%20the%20server%20what%20I%20want%20it%20to%20do%2C%20post%20build.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWithin%20Azure%20Resource%20Manager%20IaaS%20deployments%2C%20there%20are%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fextensions%2Foverview%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EVM%20extensions%3C%2FA%3E%20you%20can%20lean%20on%20for%20post-deployment%20configuration%20and%20automation%20tasks%20on%20Azure%20VMs.%20The%20extensions%20themselves%20are%20comprehensive%20and%20extensive.%20Rather%20than%20spend%20too%20much%20time%20going%20into%20what%20those%20extensions%20can%20do%20and%20why%20they%20are%20invaluable%20related%20to%20configuration%2C%20I%20want%20to%20focus%20on%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fextensions%2Fdsc-windows%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDSC%20VM%20extension%3C%2FA%3E%20specifically%2C%20as%20that%20is%20the%20extension%20my%20template%20makes%20use%20of%20during%20deployment.%20By%20using%20this%20extension%2C%20it%20uploads%20and%20applies%20a%20PowerShell%20DSC%20configuration%20on%20an%20Azure%20VM.%20During%20the%20automated%20ARM%20Template%20deployment%2C%20the%20DSC%20extension%20calls%20into%20PowerShell%20DSC%20to%20enact%20the%20received%20DSC%20configuration%20on%20the%20VM.%20So%2C%20there%20is%20no%20pull%20server%20managing%20configuration%20state%20after%20the%20VM%20is%20deployed.%20Rather%20the%20DSC%20extension%20in%20my%20template%20runs%20through%20a%20series%20of%20configurations%20I%20declare%20in%20the%20script%20before%20finishing%20deployment.%20To%20break%20it%20down%2C%20my%20script%20formats%20the%20data%20disk%2C%20joins%20the%20VM%20to%20the%20existing%20domain%2C%20adds%20the%20Active%20Directory%20Domain%20Services%20(ADDS)%20role%2C%20and%20promotes%20the%20domain%20controller.%20Pretty%20nifty%2C%20right%3F%20The%20best%20part%20is%20you%20can%20use%20this%20extension%20on%20Windows%20and%20Linux%20VMs%20(although%20I%20do%20tend%20to%20see%20Linux%20VMs%20deployed%20and%20managed%20using%20a%20configuration%20management%20tool%20like%20Ansible%2C%20Salt%20Stack%2C%20Chef%2C%20or%20Puppet).%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20actual%20DSC%20schema%20and%20example%20template%20structure%20can%20be%20found%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fextensions%2Fdsc-windows%23extension-schema%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%20I%20find%20looking%20at%20example%20code%20helpful%20if%20I%20am%20embarking%20down%20a%20path%20I%20have%20personally%20never%20traveled%20on%20before.%20Let%20us%20now%20look%20at%20how%20the%20DSC%20extension%20is%20called%20within%20my%20ARM%20Template%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22shankuehn_0-1589483082234.png%22%20style%3D%22width%3A%20722px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F191726iF555216002F1884E%2Fimage-dimensions%2F722x527%3Fv%3D1.0%22%20width%3D%22722%22%20height%3D%22527%22%20title%3D%22shankuehn_0-1589483082234.png%22%20alt%3D%22shankuehn_0-1589483082234.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESeems%20straightforward%2C%20right%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20the%20DSC%20extension%20is%20declared%20as%20an%20actual%20resource%20within%20the%20ARM%20Template%20and%20depends%20upon%20the%20vmloop%20that%20you%20use%20for%20the%20VMs%20by%20leaning%20on%20a%20copyIndex%20function%20(coupled%20with%20a%20padLeft%20%2B%20concat%20function%20to%20differentiate%20on%20names)%20from%20earlier%20(note%20this%20DSC%20extension%20configuration%20also%20makes%20use%20of%20those%20same%20functions%20within%20the%20name).%20You%20should%20also%20see%20the%20URL%20referenced%20within%20this%20resource.%20The%20extension%20expects%20to%20find%20your%20DSC%20files%20in%20a%20zip%20file%20at%20the%20URL%20specified%20and%20the%20DSC%20script%20must%20be%20in%20the%20root%20folder%20of%20the%20zip%20file.%20From%20there%2C%20the%20zip%20file%20needs%20to%20be%20accessible.%20Within%20my%20template%2C%20I%20zipped%20up%20all%20required%20modules%20and%20the%20script%20to%20host%20within%20a%20public%20GitHub%20repository.%20GitHub%20can%20serve%20up%20these%20files%20to%20your%20ARM%20Template%20during%20deployment%2C%20or%20you%20could%20lean%20on%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fextensions%2Fdsc-template%23example-using-the-configuration-script-in-azure-storage%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Blob%20Storage%3C%2FA%3E%20and%20provide%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fstorage%2Fcommon%2Fstorage-sas-overview%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3ESAS%20token%3C%2FA%3E%20like%20the%20following%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-machines%2Fextensions%2Fdsc-template%23example-using-the-configuration-script-in-azure-storage%3FWT.mc_id%3DITOPSTALK-blog-shkuehn%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eexample%3C%2FA%3E.%20I%20decided%20to%20leave%20my%20zip%20file%20up%20on%20GitHub%20so%20you%20can%20see%20just%20exactly%20how%20the%20zip%20file%20needs%20to%20be%20assembled%20for%20the%20DSC%20Extension%20to%20work%20correctly%20within%20the%20template%20deployment.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20last%20thing%20I%20want%20to%20call%20out%20are%20the%20settings%20vs.%20protected%20settings%20within%20the%20ARM%20Template.%20As%20a%20frame%20of%20reference%2C%20here%20is%20how%20they%20show%20up%20within%20my%20template%3A%3CBR%20%2F%3E%3CSTRONG%3ESettings%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22shankuehn_1-1589483082242.png%22%20style%3D%22width%3A%20730px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F191725iA1DA05AC6A597EC5%2Fimage-dimensions%2F730x135%3Fv%3D1.0%22%20width%3D%22730%22%20height%3D%22135%22%20title%3D%22shankuehn_1-1589483082242.png%22%20alt%3D%22shankuehn_1-1589483082242.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CSTRONG%3EProtected%20Settings%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22shankuehn_2-1589483082247.png%22%20style%3D%22width%3A%20543px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F191724iC6F92FE98730A339%2Fimage-dimensions%2F543x243%3Fv%3D1.0%22%20width%3D%22543%22%20height%3D%22243%22%20title%3D%22shankuehn_2-1589483082247.png%22%20alt%3D%22shankuehn_2-1589483082247.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%2C%20what%20is%20the%20difference%3F%20Well%2C%20all%20settings%20declared%20here%20for%20the%20DSC%20Extension%20are%20saved%20in%20a%20settings%20text%20file%20on%20the%20VM%20as%20the%20extension%20deploys.%20Properties%20listed%20under%20settings%20are%20public%20properties.%20Public%20properties%20are%20not%20encrypted%20in%20the%20settings%20text%20file%2C%20so%20you%20will%20not%20want%20to%20have%20any%20sort%20of%20password%20or%20important%20username%20like%20your%20Enterprise%20Administrator%20inside%20the%20template.%20Properties%20listed%20under%20protectedSettings%20are%20encrypted%20with%20a%20certificate%20and%20are%20not%20shown%20in%20plain%20text%20in%20the%20settings%20file%20on%20the%20VM.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%2C%20I%20know%20I%20am%20sort%20of%20covering%20these%20topics%20quickly%20and%20I%20want%20to%20encourage%20that%20you%20take%20time%20to%20explore%20the%20example%20code%20within%20your%20environment%20for%20a%20better%20overall%20understanding.%20As%20always%2C%20if%20you%20run%20into%20any%20snags%20or%20care%20to%20connect%20offline%20for%20a%20deeper%20discussion%2C%20do%20not%20hesitate%20to%20let%20me%20know!%20Tune%20in%20for%20the%20final%20installment%20when%20we%20go%20over%20the%20actual%20DSC%20script%20%2B%20how%20to%20troubleshoot%20(in%20the%20event%20something%20does%20not%20work%20right%20for%20you)!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1390241%22%20slang%3D%22en-US%22%3E%3CP%3EA%20quick%20walk%20through%20of%20the%20DSC%20extension%20inside%20the%20replica%20domain%20controller%20ARM%20Template.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1390241%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EShannon%20Kuehn%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20Server%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1425391%22%20slang%3D%22en-US%22%3ERe%3A%20Desired%20State%20Configuration%20Extension%20and%20the%20Replica%20Domain%20Controller%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1425391%22%20slang%3D%22en-US%22%3E%3CP%3EHey%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F682166%22%20target%3D%22_blank%22%3E%40sbugalski%3C%2FA%3E%26nbsp%3B-%20thanks%20for%20catching%20that%20right%20away.%20We've%20corrected%20the%20URL%20-%20please%20try%20again!%20Cheers!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1425392%22%20slang%3D%22en-US%22%3ERe%3A%20Desired%20State%20Configuration%20Extension%20and%20the%20Replica%20Domain%20Controller%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1425392%22%20slang%3D%22en-US%22%3E%3CP%3EWell%20-%20URLs%20-%20it%20was%20technically%203%20in%20total.%20We%20should%20be%20good%20now!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1431803%22%20slang%3D%22en-US%22%3ERe%3A%20Desired%20State%20Configuration%20Extension%20and%20the%20Replica%20Domain%20Controller%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431803%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20read%2C%20and%20great%20info!%20I%20hadn't%20done%20much%20with%20DSC%20until%20~2%20yrs%20ago%20when%20I%20started%20looking%20at%20DSC%20to%20keep%20the%20Azure%20Stack%20(Hub)%20HLH%20(Hardware%20Lifecycle%20Host)%20locked%20down%20and%20compliant%20in%20the%20solution%20I%20was%20helping%20to%20build.%20Lots%20of%20goodness%20in%20DSC%2C%20and%20handy%20stuff%20in%20the%20Gallery%20too.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1431808%22%20slang%3D%22en-US%22%3ERe%3A%20Desired%20State%20Configuration%20Extension%20and%20the%20Replica%20Domain%20Controller%20ARM%20Template%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1431808%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280295%22%20target%3D%22_blank%22%3E%40PBradz%3C%2FA%3E%26nbsp%3B-%20definitely!%20My%20last%20post%20will%20highlight%20the%20spots%20to%20go%20where%20you%20can%20get%20started%20and%20learn%20it%20better.%20I%20do%20wish%20some%20of%20this%20was%20publicized%20a%20bit%20better%2C%20but%20we're%20getting%20there.%20My%20hope%20is%20to%20at%20least%20get%20some%20folks%20embracing%20it%20for%20config%20management%20and%20highlight%20what%20it's%20doing%20within%20the%20template!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

By now, you have probably examined my code (if not, please click the link). If you are familiar with ARM Templates, the code should seem relatively straightforward. There is one piece that may seem foreign though: the Desired State Configuration (or DSC) extension. I wanted to take some time out and unpack the DSC extension within your ARM Template configuration. From there, the last post will surround the DSC script plus how to troubleshoot if something does not work right (these topics are ever so slightly mysterious at times).

 

First off, let us dig into what DSC is related to infrastructure as code. The management and maintenance of servers becomes difficult and challenging as time evolves plus configurations change. In the sysadmin world, we tend to end up with a plethora of scripts to manage a server and usually those scripts live on some sort of utils server or UNC share. With the cloud, that legacy practice just does not scale (unfortunately). With cloud, we need a better way to automate a task (and maybe even a series of tasks) or a configuration state to prevent configuration drift among servers. DSC is a declarative way of leaning on PowerShell scripts, where you define and configure instances of resources. Upon running configurations, DSC ensures the configurations match up with a predefined state all servers should hold. These configurations are also idempotent: The Local Configuration Manager (LCM) continues to ensure that machines are configured in whatever state the configuration declares. Typically, these configurations exist on some sort of pull server. The pull server is an automation server that allows all configurations to be maintained on many servers across a network.

 

Seems simple as a concept and a powerful reality that all sysadmins should be adopting, right? Right. After reading through these descriptions, you may be wondering how DSC works with my ARM Template and that is ever so slightly different. I want to shed some light, as I am not deploying a pull server, but I am using a DSC script + a DSC extension to tell the server what I want it to do, post build.

 

Within Azure Resource Manager IaaS deployments, there are VM extensions you can lean on for post-deployment configuration and automation tasks on Azure VMs. The extensions themselves are comprehensive and extensive. Rather than spend too much time going into what those extensions can do and why they are invaluable related to configuration, I want to focus on the DSC VM extension specifically, as that is the extension my template makes use of during deployment. By using this extension, it uploads and applies a PowerShell DSC configuration on an Azure VM. During the automated ARM Template deployment, the DSC extension calls into PowerShell DSC to enact the received DSC configuration on the VM. So, there is no pull server managing configuration state after the VM is deployed. Rather the DSC extension in my template runs through a series of configurations I declare in the script before finishing deployment. To break it down, my script formats the data disk, joins the VM to the existing domain, adds the Active Directory Domain Services (ADDS) role, and promotes the domain controller. Pretty nifty, right? The best part is you can use this extension on Windows and Linux VMs (although I do tend to see Linux VMs deployed and managed using a configuration management tool like Ansible, Salt Stack, Chef, or Puppet).

 

The actual DSC schema and example template structure can be found here. I find looking at example code helpful if I am embarking down a path I have personally never traveled on before. Let us now look at how the DSC extension is called within my ARM Template:

shankuehn_0-1589483082234.png

 

Seems straightforward, right?

 

So the DSC extension is declared as an actual resource within the ARM Template and depends upon the vmloop that you use for the VMs by leaning on a copyIndex function (coupled with a padLeft + concat function to differentiate on names) from earlier (note this DSC extension configuration also makes use of those same functions within the name). You should also see the URL referenced within this resource. The extension expects to find your DSC files in a zip file at the URL specified and the DSC script must be in the root folder of the zip file. From there, the zip file needs to be accessible. Within my template, I zipped up all required modules and the script to host within a public GitHub repository. GitHub can serve up these files to your ARM Template during deployment, or you could lean on Azure Blob Storage and provide a SAS token like the following example. I decided to leave my zip file up on GitHub so you can see just exactly how the zip file needs to be assembled for the DSC Extension to work correctly within the template deployment.

 

One last thing I want to call out are the settings vs. protected settings within the ARM Template. As a frame of reference, here is how they show up within my template:
Settings

shankuehn_1-1589483082242.png

 


Protected Settings

shankuehn_2-1589483082247.png

 

So, what is the difference? Well, all settings declared here for the DSC Extension are saved in a settings text file on the VM as the extension deploys. Properties listed under settings are public properties. Public properties are not encrypted in the settings text file, so you will not want to have any sort of password or important username like your Enterprise Administrator inside the template. Properties listed under protectedSettings are encrypted with a certificate and are not shown in plain text in the settings file on the VM.

 

Now, I know I am sort of covering these topics quickly and I want to encourage that you take time to explore the example code within your environment for a better overall understanding. As always, if you run into any snags or care to connect offline for a deeper discussion, do not hesitate to let me know! Tune in for the final installment when we go over the actual DSC script + how to troubleshoot (in the event something does not work right for you)!

5 Comments
Regular Visitor

Hi @shankuehn thanks for your article.

 

I found two links have malformed URL.

http://%20https//

 

Microsoft

Hey  @sbugalski - thanks for catching that right away. We've corrected the URL - please try again! Cheers!

Microsoft

Well - URLs - it was technically 3 in total. We should be good now!

New Contributor

Good read, and great info! I hadn't done much with DSC until ~2 yrs ago when I started looking at DSC to keep the Azure Stack (Hub) HLH (Hardware Lifecycle Host) locked down and compliant in the solution I was helping to build. Lots of goodness in DSC, and handy stuff in the Gallery too.

Microsoft

@PBradz - definitely! My last post will highlight the spots to go where you can get started and learn it better. I do wish some of this was publicized a bit better, but we're getting there. My hope is to at least get some folks embracing it for config management and highlight what it's doing within the template!