%3CLINGO-SUB%20id%3D%22lingo-sub-1457687%22%20slang%3D%22en-US%22%3EAugmenting%20Azure%20Advisor%20Cost%20Recommendations%20for%20Automated%20Continuous%20Optimization%20%E2%80%93%20Part%202%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1457687%22%20slang%3D%22en-US%22%3E%3CP%3E%3CEM%3EThis%20is%20the%20second%20post%20of%20a%20series%20dedicated%20to%20the%20implementation%20of%20automated%20Continuous%20Optimization%20with%20Azure%20Advisor%20Cost%20recommendations.%20For%20a%20contextualization%20of%20the%20solution%20described%20in%20this%20and%20following%20posts%2C%20please%20read%20the%20%3C%2FEM%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fcore-infrastructure-and-security%2Faugmenting-azure-advisor-cost-recommendations-for-automated%2Fba-p%2F1339298%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Eintroductory%20post%3C%2FA%3E%3C%2FSPAN%3E%3CEM%3E.%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1324047786%22%20id%3D%22toc-hId--1324047786%22%3E%3CSPAN%3EIntroduction%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EAs%20we%20saw%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fcore-infrastructure-and-security%2Faugmenting-azure-advisor-cost-recommendations-for-automated%2Fba-p%2F1339298%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Eprevious%20post%3C%2FA%3E%2C%20if%20we%20want%20to%20build%20higher%20confidence%20on%20Azure%20Advisor%20right-size%20recommendations%20and%20better%20inform%20decisions%2C%20we%20need%20to%20combine%20Advisor%20recommendations%20with%20additional%20data%20coming%20from%20other%20sources%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3EFirst%2C%20we%20need%20Virtual%20Machines%20performance%20metrics%20to%20give%20visibility%20about%20why%20Advisor%20is%20recommending%20a%20downsize%20or%20shutdown.%20We%20need%20at%20least%20the%20last%207%20days%20of%20aggregated%20metrics.%20There%20are%20many%20ways%20of%20collecting%20performance%20metrics%20for%20VMs%20in%20Azure%20%E2%80%93%20Azure%20Monitor%20platform%20metrics%2C%20Azure%20Log%20Analytics%20or%20Azure%20Diagnostics%20guest%20agent%2C%20or%20even%20a%20third-party%20monitoring%20solution.%20As%20we%20want%20to%20combine%20all%20data%20together%20into%20a%20single%20repository%2C%20using%20the%20Azure%20Log%20Analytics%20agent%20is%20the%20simplest%20approach%2C%20as%20performance%20metrics%20will%20automatically%20land%20where%20they%20will%20later%20be%20queried%20from.%20Of%20course%2C%20if%20you%20do%20not%20(or%20don%E2%80%99t%20want%20to)%20monitor%20your%20VMs%20with%20the%20Log%20Analytics%20agent%2C%20you%20can%20still%20ingest%20into%20Log%20Analytics%20the%20performance%20metrics%20aggregates%20coming%20from%20your%20favorite%20source.%20This%20series%20will%20only%20cover%20the%20Log%20Analytics%20agent%20scenario%2C%20though.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ETo%20validate%20whether%20a%20SKU%20recommended%20by%20Advisor%20can%20actually%20be%20used%20for%20a%20specific%20VM%2C%20we%20must%20check%20how%20many%20data%20disks%20and%20network%20interfaces%20are%20being%20used%2C%20as%20all%20SKUs%20have%20limits%20regarding%20these%20resources.%20The%20quickest%20and%20simplest%20way%20to%20get%20that%20information%20is%20to%20query%20Azure%20Resource%20Graph%20(ARG)%20for%20all%20our%20VMs.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EFinally%2C%20if%20we%20want%20to%20validate%20if%20the%20current%20disk%20IOPS%20and%20throughput%20profile%20are%20supported%20in%20the%20recommended%20SKU%2C%20we%20must%20collect%20data%20about%20all%20VM%20disks%2C%20namely%20disk%20type%20(OS%20vs.%20data)%20and%20host%20caching%20options.%20Again%2C%20we%20will%20call%20ARG%20to%20the%20rescue!%20And%20having%20disks%20data%2C%20we%20can%20easily%20get%20an%20extra%20recommendation%20not%20yet%20supported%20by%20Advisor%20%E2%80%93%20guess%20what%20(more%20details%20in%20the%20next%20post%20%3C%2FSPAN%3E%3Asmiling_face_with_smiling_eyes%3A%3CSPAN%3E)!%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENow%20let%E2%80%99s%20look%20at%20each%20of%20these%20data%20sources%20in%20detail%20and%20start%20building%20our%20Azure%20Optimization%20Engine%20pipeline.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1163465047%22%20id%3D%22toc-hId-1163465047%22%3E%3CSPAN%3ECollecting%20Virtual%20Machine%20performance%20metrics%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EI%20am%20not%20going%20into%20the%20details%20of%20configuring%20the%20Log%20Analytics%20agent%20in%20your%20Azure%20Virtual%20Machines%2C%20as%20you%20have%20very%20good%20guidance%20in%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Flog-analytics-agent%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eofficial%20documentation%3C%2FA%3E.%20For%20collecting%20performance%20metrics%20with%20the%20Log%20Analytics%20agent%2C%20you%20have%20two%20options%3A%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Finsights%2Fvminsights-performance%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EVM%20Insights%20solution%3C%2FA%3E%20and%20the%20agent%20native%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-monitor%2Fplatform%2Fdata-sources-performance-counters%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EPerf%20solution%3C%2FA%3E.%20This%20series%20covers%20the%20latter%20option%2C%20as%20it%20provides%20more%20control%20over%20the%20metrics%20and%20collection%20intervals%20and%20we%20also%20want%20to%20optimize%20Azure%20consumption%20in%20the%20optimization%20tool%20itself%20%3C%2FSPAN%3E%3B)%3C%2Fimg%3E%3CSPAN%3E%20So%2C%20besides%20having%20all%20your%20VMs%20onboarded%20to%20Log%20Analytics%2C%20go%20to%20the%20Advanced%20Settings%20%26gt%3B%20Data%20blade%20and%20configure%20at%20least%20the%20following%20counters%20(if%20you%20already%20had%20your%20VMs%20being%20monitored%20by%20Log%20Analytics%2C%20then%20you%20just%20need%20to%20check%20if%20all%20needed%20counters%20are%20there)%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3EWindows%3C%2FSPAN%3E%3CUL%3E%0A%3CLI%3E%3CSPAN%3ELogicalDisk(*)%5CDisk%20Read%20Bytes%2Fsec%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ELogicalDisk(*)%5CDisk%20Reads%2Fsec%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ELogicalDisk(*)%5CDisk%20Write%20Bytes%2Fsec%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ELogicalDisk(*)%5CDisk%20Writes%2Fsec%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EMemory(*)%5CAvailable%20MBytes%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ENetwork%20Adapter(*)%5CBytes%20Total%2Fsec%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EProcessor(*)%5C%25%20Processor%20Time%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ELinux%3C%2FSPAN%3E%3CUL%3E%0A%3CLI%3E%3CSPAN%3ELogicalDisk(*)%5CDisk%20Read%20Bytes%2Fsec%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ELogicalDisk(*)%5CDisk%20Reads%2Fsec%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ELogicalDisk(*)%5CDisk%20Write%20Bytes%2Fsec%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ELogicalDisk(*)%5CDisk%20Writes%2Fsec%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EMemory(*)%5CAvailable%20MBytes%20Memory%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ENetwork(*)%5CTotal%20Bytes%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3EProcessor(*)%5C%25%20Processor%20Time%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%3EDisk%20counters%20need%20to%20be%20separated%20in%20both%20read%20and%20write%20dimensions%2C%20because%20of%20the%20impact%20of%20read%2Fwrite%20host%20caching%20definitions%20-%20when%20looking%20at%20disk%20performance%2C%20we%20must%20consider%20cached%20vs.%20non-cached%20virtual%20machine%20disk%20throughput%2FIOPS%20limits.%20For%20the%20same%20reason%2C%20we%20need%20to%20collect%20metrics%20for%20all%20disk%20instances%2C%20because%20host%20caching%20is%20defined%20per%20disk.%20Network%20throughput%20is%20collected%20as%20totals%2C%20because%20network%20bandwidth%20limits%20are%20independent%20of%20network%20adapter%20or%20direction.%20Processor%20metrics%20are%20collected%20for%20all%20CPU%20instances%2C%20because%20overall%20percentages%20can%20be%20misleading%20(e.g.%2C%2050%25%20total%20CPU%20usage%20may%20be%20a%20result%20of%20100%25%20usage%20in%201%20core%20and%200%25%20in%20another).%20Each%20performance%20counter%20instance%20collected%20at%20a%2060%20second%20interval%20consumes%20about%20430%20KB%20per%20computer%20per%20day%20in%20Log%20Analytics.%20In%20a%20scenario%20with%204%20logical%20disks%20and%204%20CPU%20cores%2C%20each%20computer%20would%20generate%2027%20performance%20counter%20instances%20(20%20for%20logical%20disk%2C%201%20for%20memory%2C%201%20for%20network%20adapter%20and%205%20for%20processor).%20If%20all%20performance%20counters%20were%20collected%20at%20the%20same%2060%20seconds%20frequency%2C%20each%20computer%20would%20generate%20~11%20MB%20of%20data%20per%20day.%20Of%20course%2C%20you%20can%20adjust%20the%20collection%20interval%20for%20some%20counters%2C%20if%20you%20want%20your%20solution%20to%20be%20costs-savvy%20(see%20example%20below).%3C%2FSPAN%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%22augmenting-azure-advisor-co-pt2-figure1.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F198237i3BA5E0F703261556%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22augmenting-azure-advisor-co-pt2-figure1.jpg%22%20alt%3D%22augmenting-azure-advisor-co-pt2-figure1.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--643989416%22%20id%3D%22toc-hId--643989416%22%3E%3CSPAN%3ECollecting%20Virtual%20Machine%20and%20Managed%20Disks%20properties%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ECollecting%20VM%20and%20disks%20properties%20with%20ARG%20is%20super%20easy.%20The%20VM%20queries%20are%20straightforward%20and%20self-explanatory%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eresources%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%26nbsp%3Btype%26nbsp%3B%3D~%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3E'Microsoft.Compute%2FvirtualMachines'%3C%2FFONT%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eextend%3C%2FFONT%3E%26nbsp%3BdataDiskCount%26nbsp%3B%3D%26nbsp%3Barray_length(properties.storageProfile.dataDisks)%2C%26nbsp%3BnicCount%26nbsp%3B%3D%26nbsp%3Barray_length(properties.networkProfile.networkInterfaces)%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eorder%26nbsp%3Bby%3C%2FFONT%3E%26nbsp%3Bid%26nbsp%3Basc%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%E2%80%A6%20for%20ARM%20VMs%20and%20%E2%80%A6%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eresources%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%26nbsp%3Btype%26nbsp%3B%3D~%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3E'Microsoft.ClassicCompute%2FvirtualMachines'%3C%2FFONT%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eextend%3C%2FFONT%3E%26nbsp%3BdataDiskCount%26nbsp%3B%3D%26nbsp%3Biif(isnotnull(properties.storageProfile.dataDisks)%2C%26nbsp%3Barray_length(properties.storageProfile.dataDisks)%2C%26nbsp%3B0)%2C%26nbsp%3BnicCount%26nbsp%3B%3D%26nbsp%3Biif(isnotnull(properties.networkProfile.virtualNetwork.networkInterfaces)%2C%26nbsp%3Barray_length(properties.networkProfile.virtualNetwork.networkInterfaces)%26nbsp%3B%2B%26nbsp%3B1%2C%26nbsp%3B1)%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eorder%26nbsp%3Bby%26nbsp%3Bid%3C%2FFONT%3E%26nbsp%3Basc%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%E2%80%A6%20for%20Classic%20VMs.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFor%20Managed%20Disks%2C%20the%20query%20is%20more%20complicated%2C%20because%20we%20want%20to%20distinguish%20between%20OS%20and%20Data%20disks%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eresources%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%26nbsp%3Btype%26nbsp%3B%3D~%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3E'Microsoft.Compute%2Fdisks'%3C%2FFONT%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eextend%3C%2FFONT%3E%26nbsp%3BDiskId%26nbsp%3B%3D%26nbsp%3Btolower(id)%2C%26nbsp%3BOwnerVmId%26nbsp%3B%3D%26nbsp%3Btolower(managedBy)%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Ejoin%3C%2FFONT%3E%26nbsp%3Bkind%3Dleftouter%26nbsp%3B(%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bresources%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%26nbsp%3Btype%26nbsp%3B%3D~%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3E'Microsoft.Compute%2FvirtualMachines'%3C%2FFONT%3E%26nbsp%3Band%26nbsp%3Barray_length(properties.storageProfile.dataDisks)%26nbsp%3B%26gt%3B%26nbsp%3B0%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eextend%3C%2FFONT%3E%26nbsp%3BOwnerVmId%26nbsp%3B%3D%26nbsp%3Btolower(id)%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3Bmv-expand%26nbsp%3BDataDisks%26nbsp%3B%3D%26nbsp%3Bproperties.storageProfile.dataDisks%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eextend%3C%2FFONT%3E%26nbsp%3BDiskId%26nbsp%3B%3D%26nbsp%3Btolower(DataDisks.managedDisk.id)%2C%26nbsp%3BdiskCaching%26nbsp%3B%3D%26nbsp%3Btostring(DataDisks.caching)%2C%26nbsp%3BdiskType%26nbsp%3B%3D%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3E'Data'%3C%2FFONT%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eproject%3C%2FFONT%3E%26nbsp%3BDiskId%2C%26nbsp%3BOwnerVmId%2C%26nbsp%3BdiskCaching%2C%26nbsp%3BdiskType%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eunion%3C%2FFONT%3E%26nbsp%3B(%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bresources%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Ewhere%3C%2FFONT%3E%26nbsp%3Btype%26nbsp%3B%3D~%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3E'Microsoft.Compute%2FvirtualMachines'%3C%2FFONT%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eextend%3C%2FFONT%3E%26nbsp%3BOwnerVmId%26nbsp%3B%3D%26nbsp%3Btolower(id)%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eextend%3C%2FFONT%3E%26nbsp%3BDiskId%26nbsp%3B%3D%26nbsp%3Btolower(properties.storageProfile.osDisk.managedDisk.id)%2C%26nbsp%3BdiskCaching%26nbsp%3B%3D%26nbsp%3Btostring(properties.storageProfile.osDisk.caching)%2C%26nbsp%3BdiskType%26nbsp%3B%3D%26nbsp%3B%3CFONT%20color%3D%22%23FF0000%22%3E'OS'%3C%2FFONT%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eproject%3C%2FFONT%3E%26nbsp%3BDiskId%2C%26nbsp%3BOwnerVmId%2C%26nbsp%3BdiskCaching%2C%26nbsp%3BdiskType%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B)%3C%2FP%3E%0A%3CP%3E)%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eon%3C%2FFONT%3E%26nbsp%3BOwnerVmId%2C%26nbsp%3BDiskId%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eproject-away%3C%2FFONT%3E%26nbsp%3BOwnerVmId%2C%26nbsp%3BDiskId%2C%26nbsp%3BOwnerVmId1%2C%26nbsp%3BDiskId1%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%7C%26nbsp%3B%3CFONT%20color%3D%22%230000FF%22%3Eorder%26nbsp%3Bby%3C%2FFONT%3E%26nbsp%3Bid%26nbsp%3Basc%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENo%20support%20for%20Classic%20VM%20disks%2C%20though%2C%20as%20they%20are%20unmanaged%20resources%20lying%20as%20a%20page%20blob%20in%20some%20Azure%20Storage%20container.%20Contributors%20are%20welcome!%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFor%20larger%20environments%2C%20we%E2%80%99ll%20need%20to%20implement%20pagination%20as%20ARG%20only%20returns%20the%20first%201000%20rows%20for%20each%20query%20(the%20ARG%20runbooks%20scripts%20below%20will%20show%20you%20how).%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1843523417%22%20id%3D%22toc-hId-1843523417%22%3E%3CSPAN%3EDeploying%20the%20Azure%20Optimization%20Engine%20(data%20collection)%3C%2FSPAN%3E%3C%2FH2%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ENow%20that%20we%20have%20some%20ground%20about%20the%20data%20we%20need%20to%20collect%2C%20we%20can%20finally%20start%20deploying%20the%20Azure%20Optimization%20Engine%20(AOE)%20solution!%20We%20are%20just%20looking%20at%20data%20collection%20for%20the%20moment%20%E2%80%93%20no%20augmented%20recommendations%20yet%20%E2%80%93%20but%20we%20will%20deploy%20here%20all%20the%20necessary%20foundations%20for%20the%20complete%20solution%20to%20be%20presented%20in%20the%20upcoming%20posts.%20In%20the%20links%20below%2C%20you%E2%80%99ll%20be%20directed%20to%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fhelderpinto%2FAzureOptimizationEngine%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAOE%20repository%3C%2FA%3E%2C%20where%20you%E2%80%99ll%20find%20sooner%20or%20later%20the%20complete%20working%20solution.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20AOE%20solution%20is%20made%20of%20the%20following%20building%20blocks%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fhelderpinto%2FAzureOptimizationEngine%2Fblob%2Fmaster%2Fazuredeploy.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EARM%20template%3C%2FA%3E%20deploying%20Azure%20Automation%20account%2C%20runbooks%20and%20all%20required%20automation%20assets%2C%20Storage%20Account%2C%20SQL%20Database%20and%2C%20if%20needed%2C%20Log%20Analytics%20workspace.%20You%20can%20choose%20to%20reuse%20an%20existing%20Log%20Analytics%20workspace%20in%20case%20you%20were%20already%20monitoring%20your%20VMs%20before.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fhelderpinto%2FAzureOptimizationEngine%2Fblob%2Fmaster%2Frunbooks%2Fdata-collection%2FExport-AdvisorCostRecommendationsToBlobStorage.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EExport-AdvisorCostRecommendationsToBlobStorage%20runbook%3C%2FA%3E%20%E2%80%93%20collects%20from%20Advisor%20API%20the%20most%20recent%20Cost%20recommendations%20and%20dumps%20them%20as%20CSV%20into%20a%20blob%20container.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fhelderpinto%2FAzureOptimizationEngine%2Fblob%2Fmaster%2Frunbooks%2Fdata-collection%2FExport-ARGVirtualMachinesPropertiesToBlobStorage.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EExport-ARGVirtualMachinesPropertiesToBlobStorage%20runbook%3C%2FA%3E%20%E2%80%93%20collects%20from%20ARG%20the%20whole%20list%20of%20VMs%20and%20respective%20properties%20and%20dumps%20them%20as%20CSV%20into%20a%20different%20blob%20container.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fhelderpinto%2FAzureOptimizationEngine%2Fblob%2Fmaster%2Frunbooks%2Fdata-collection%2FExport-ARGManagedDisksPropertiesToBlobStorage.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EExport-ARGManagedDisksPropertiesToBlobStorage%20runbook%3C%2FA%3E%20%E2%80%93%20collects%20from%20ARG%20the%20whole%20list%20of%20Managed%20Disks%20and%20respective%20properties%20and%20dumps%20them%20as%20CSV%20into%20a%20different%20blob%20container.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fhelderpinto%2FAzureOptimizationEngine%2Fblob%2Fmaster%2Frunbooks%2Fdata-collection%2FIngest-OptimizationCSVExportsToLogAnalytics.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EIngest-OptimizationCSVExportsToLogAnalytics%20runbook%3C%2FA%3E%20%E2%80%93%20scans%20a%20blob%20container%20and%20ingests%20all%20the%20unprocessed%20CSV%20blobs%20into%20a%20custom%20Log%20Analytics%20table%20(content%20type%20specific).%20To%20keep%20track%20of%20the%20CSV%20and%20number%20of%20CSV%20lines%20already%20processed%2C%20this%20runbook%20depends%20on%20a%20SQL%20Database%2C%20where%20it%20also%20gets%20details%20about%20the%20custom%20Log%20Analytics%20table%20corresponding%20to%20each%20%26nbsp%3BCSV%20type.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fhelderpinto%2FAzureOptimizationEngine%2Fblob%2Fmaster%2FDeploy-AzureOptimizationEngine.ps1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeploy-AzureAutomationEngine.ps1%3C%2FA%3E%20%E2%80%93%20full%20deployment%20script%20which%20kicks%20off%20the%20ARM%20template%20deployment%20and%20sets%20up%20the%20SQL%20Database%20at%20the%20end.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESo%2C%20to%20deploy%20the%20AOE%2C%20you%20just%20need%20to%20run%20the%20Deploy-AzureAutomationEngine%20script%20%3CSTRONG%3Ein%20an%20elevated%20prompt%3C%2FSTRONG%3E%20and%20authenticating%20to%20Azure%20with%20a%20user%20account%20having%20%3CSTRONG%3EOwner%20permissions%20over%20the%20chosen%20subscription%20and%20enough%20privileges%20to%20register%20Azure%20AD%20applications%3C%2FSTRONG%3E%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fautomation%2Fmanage-runas-account%23permissions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Esee%20details%3C%2FA%3E).%20You%E2%80%99ll%20be%20asked%20several%20details%20about%20your%20deployment%20options%2C%20including%20whether%20you%20want%20to%20reuse%20an%20existing%20Log%20Analytics%20workspace%20or%20start%20with%20a%20new%20one.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EThe%20deployment%20will%20take%20some%20minutes%20to%20complete%20and%20you%E2%80%99ll%20then%20be%20asked%20to%20enter%20a%20password%20for%20the%20Run%20As%20certificate%20for%20the%20Automation%20account.%20A%20couple%20of%20minutes%20more%20and%20the%20script%20will%20hopefully%20terminate%20successfully.%20In%20the%20event%20of%20an%20error%2C%20you%20can%20re-deploy%20with%20the%20same%20parameters%2C%20as%20the%20process%20is%20idempotent.%20You%20can%20check%20the%20Automation%20Account%20schedules%20created%20by%20the%20deployment%20(see%20picture%20below)%2C%20which%20will%20trigger%20in%20a%20matter%20of%20a%201-2-hour%20timeframe.%3C%2FSPAN%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%22augmenting-azure-advisor-co-pt2-figure2.jpg%22%20style%3D%22width%3A%20975px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F198238iD71802D1AF637CF1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22augmenting-azure-advisor-co-pt2-figure2.jpg%22%20alt%3D%22augmenting-azure-advisor-co-pt2-figure2.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3ESome%20minutes%20after%20all%20the%20ingestion%20runbooks%20run%2C%20you%E2%80%99ll%20be%20able%20to%20query%20in%20Log%20Analytics%20for%20those%20tables.%20We%E2%80%99ll%20make%20use%20of%20these%20records%20to%20generate%20our%20recommendations.%3C%2FSPAN%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%22augmenting-azure-advisor-co-pt2-figure3.jpg%22%20style%3D%22width%3A%20975px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F198239iC95EA1AB93216E05%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22augmenting-azure-advisor-co-pt2-figure3.jpg%22%20alt%3D%22augmenting-azure-advisor-co-pt2-figure3.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20successfully%20deployed%2C%20and%20assuming%20you%20have%20your%20VMs%20onboarded%20to%20Log%20Analytics%20and%20collecting%20all%20the%20required%20performance%20counters%2C%20we%20have%20everything%20that%20is%20needed%20to%20start%20augmenting%20Advisor%20recommendations%20and%20even%20generate%20custom%20ones!%20Let%20it%20boil%20for%20some%20weeks%20and%20keep%20tuned%20%E2%80%93%20in%20the%20next%20post%2C%20we%E2%80%99re%20discussing%20how%20AOE%20produces%20the%20actual%20recommendations%20and%20we%E2%80%99ll%20going%20to%20finally%20see%20some%20light!%20%3CIMG%20class%3D%22lia-deferred-image%20lia-image-emoji%22%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Fhtml%2Fimages%2Femoticons%2Flaugh_40x40.gif%22%20alt%3D%22%3Alol%3A%22%20title%3D%22%3Alol%3A%22%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1457687%22%20slang%3D%22en-US%22%3E%3CP%3E%3CEM%3EThis%20is%20the%20second%20post%20of%20a%20series%20dedicated%20to%20the%20implementation%20of%20automated%20Continuous%20Optimization%20with%20Azure%20Advisor%20Cost%20recommendations.%20For%20a%20contextualization%20of%20the%20solution%20described%20in%20this%20and%20following%20posts%2C%20please%20read%20the%20%3C%2FEM%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fcore-infrastructure-and-security%2Faugmenting-azure-advisor-cost-recommendations-for-automated%2Fba-p%2F1339298%22%20target%3D%22_blank%22%3Eintroductory%20post%3C%2FA%3E%3CEM%3E.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22augmenting-azure-advisor-co-pt2-figure1.jpg%22%20style%3D%22width%3A%20975px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F198233i257F278B1F72C85C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22augmenting-azure-advisor-co-pt2-figure1.jpg%22%20alt%3D%22augmenting-azure-advisor-co-pt2-figure1.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FEM%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1457687%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EHelderPinto%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

This is the second post of a series dedicated to the implementation of automated Continuous Optimization with Azure Advisor Cost recommendations. For a contextualization of the solution described in this and following posts, please read the introductory post.

 

Introduction

 

As we saw in the previous post, if we want to build higher confidence on Azure Advisor right-size recommendations and better inform decisions, we need to combine Advisor recommendations with additional data coming from other sources:

 

  • First, we need Virtual Machines performance metrics to give visibility about why Advisor is recommending a downsize or shutdown. We need at least the last 7 days of aggregated metrics. There are many ways of collecting performance metrics for VMs in Azure – Azure Monitor platform metrics, Azure Log Analytics or Azure Diagnostics guest agent, or even a third-party monitoring solution. As we want to combine all data together into a single repository, using the Azure Log Analytics agent is the simplest approach, as performance metrics will automatically land where they will later be queried from. Of course, if you do not (or don’t want to) monitor your VMs with the Log Analytics agent, you can still ingest into Log Analytics the performance metrics aggregates coming from your favorite source. This series will only cover the Log Analytics agent scenario, though.
  • To validate whether a SKU recommended by Advisor can actually be used for a specific VM, we must check how many data disks and network interfaces are being used, as all SKUs have limits regarding these resources. The quickest and simplest way to get that information is to query Azure Resource Graph (ARG) for all our VMs.
  • Finally, if we want to validate if the current disk IOPS and throughput profile are supported in the recommended SKU, we must collect data about all VM disks, namely disk type (OS vs. data) and host caching options. Again, we will call ARG to the rescue! And having disks data, we can easily get an extra recommendation not yet supported by Advisor – guess what (more details in the next post :smiling_face_with_smiling_eyes:)!

 

Now let’s look at each of these data sources in detail and start building our Azure Optimization Engine pipeline.

 

Collecting Virtual Machine performance metrics

 

I am not going into the details of configuring the Log Analytics agent in your Azure Virtual Machines, as you have very good guidance in the official documentation. For collecting performance metrics with the Log Analytics agent, you have two options: the VM Insights solution and the agent native Perf solution. This series covers the latter option, as it provides more control over the metrics and collection intervals and we also want to optimize Azure consumption in the optimization tool itself ;) So, besides having all your VMs onboarded to Log Analytics, go to the Advanced Settings > Data blade and configure at least the following counters (if you already had your VMs being monitored by Log Analytics, then you just need to check if all needed counters are there):

 

  • Windows
    • LogicalDisk(*)\Disk Read Bytes/sec
    • LogicalDisk(*)\Disk Reads/sec
    • LogicalDisk(*)\Disk Write Bytes/sec
    • LogicalDisk(*)\Disk Writes/sec
    • Memory(*)\Available MBytes
    • Network Adapter(*)\Bytes Total/sec
    • Processor(*)\% Processor Time
  • Linux
    • LogicalDisk(*)\Disk Read Bytes/sec
    • LogicalDisk(*)\Disk Reads/sec
    • LogicalDisk(*)\Disk Write Bytes/sec
    • LogicalDisk(*)\Disk Writes/sec
    • Memory(*)\Available MBytes Memory
    • Network(*)\Total Bytes
    • Processor(*)\% Processor Time

Disk counters need to be separated in both read and write dimensions, because of the impact of read/write host caching definitions - when looking at disk performance, we must consider cached vs. non-cached virtual machine disk throughput/IOPS limits. For the same reason, we need to collect metrics for all disk instances, because host caching is defined per disk. Network throughput is collected as totals, because network bandwidth limits are independent of network adapter or direction. Processor metrics are collected for all CPU instances, because overall percentages can be misleading (e.g., 50% total CPU usage may be a result of 100% usage in 1 core and 0% in another). Each performance counter instance collected at a 60 second interval consumes about 430 KB per computer per day in Log Analytics. In a scenario with 4 logical disks and 4 CPU cores, each computer would generate 27 performance counter instances (20 for logical disk, 1 for memory, 1 for network adapter and 5 for processor). If all performance counters were collected at the same 60 seconds frequency, each computer would generate ~11 MB of data per day. Of course, you can adjust the collection interval for some counters, if you want your solution to be costs-savvy (see example below).

 

augmenting-azure-advisor-co-pt2-figure1.jpg

 

Collecting Virtual Machine and Managed Disks properties

 

Collecting VM and disks properties with ARG is super easy. The VM queries are straightforward and self-explanatory:

 

resources

where type =~ 'Microsoft.Compute/virtualMachines' 

extend dataDiskCount = array_length(properties.storageProfile.dataDisks), nicCount = array_length(properties.networkProfile.networkInterfaces) 

order by id asc

 

… for ARM VMs and …

 

resources

where type =~ 'Microsoft.ClassicCompute/virtualMachines' 

extend dataDiskCount = iif(isnotnull(properties.storageProfile.dataDisks), array_length(properties.storageProfile.dataDisks), 0), nicCount = iif(isnotnull(properties.networkProfile.virtualNetwork.networkInterfaces), array_length(properties.networkProfile.virtualNetwork.networkInterfaces) + 1, 1) 

order by id asc

 

… for Classic VMs.

 

For Managed Disks, the query is more complicated, because we want to distinguish between OS and Data disks:

 

resources 

where type =~ 'Microsoft.Compute/disks' 

extend DiskId = tolower(id), OwnerVmId = tolower(managedBy) 

join kind=leftouter (

    resources 

    | where type =~ 'Microsoft.Compute/virtualMachines' and array_length(properties.storageProfile.dataDisks) > 0 

    | extend OwnerVmId = tolower(id) 

    | mv-expand DataDisks = properties.storageProfile.dataDisks 

    | extend DiskId = tolower(DataDisks.managedDisk.id), diskCaching = tostring(DataDisks.caching), diskType = 'Data' 

    | project DiskId, OwnerVmId, diskCaching, diskType 

    | union (

        resources 

        | where type =~ 'Microsoft.Compute/virtualMachines' 

        | extend OwnerVmId = tolower(id) 

        | extend DiskId = tolower(properties.storageProfile.osDisk.managedDisk.id), diskCaching = tostring(properties.storageProfile.osDisk.caching), diskType = 'OS' 

        | project DiskId, OwnerVmId, diskCaching, diskType

    )

on OwnerVmId, DiskId 

project-away OwnerVmId, DiskId, OwnerVmId1, DiskId1 

order by id asc

 

No support for Classic VM disks, though, as they are unmanaged resources lying as a page blob in some Azure Storage container. Contributors are welcome!

 

For larger environments, we’ll need to implement pagination as ARG only returns the first 1000 rows for each query (the ARG runbooks scripts below will show you how).

 

Deploying the Azure Optimization Engine (data collection)

 

Now that we have some ground about the data we need to collect, we can finally start deploying the Azure Optimization Engine (AOE) solution! We are just looking at data collection for the moment – no augmented recommendations yet – but we will deploy here all the necessary foundations for the complete solution to be presented in the upcoming posts. In the links below, you’ll be directed to the AOE repository, where you’ll find sooner or later the complete working solution.

 

The AOE solution is made of the following building blocks:

 

  • ARM template deploying Azure Automation account, runbooks and all required automation assets, Storage Account, SQL Database and, if needed, Log Analytics workspace. You can choose to reuse an existing Log Analytics workspace in case you were already monitoring your VMs before.
  • Export-AdvisorCostRecommendationsToBlobStorage runbook – collects from Advisor API the most recent Cost recommendations and dumps them as CSV into a blob container.
  • Export-ARGVirtualMachinesPropertiesToBlobStorage runbook – collects from ARG the whole list of VMs and respective properties and dumps them as CSV into a different blob container.
  • Export-ARGManagedDisksPropertiesToBlobStorage runbook – collects from ARG the whole list of Managed Disks and respective properties and dumps them as CSV into a different blob container.
  • Ingest-OptimizationCSVExportsToLogAnalytics runbook – scans a blob container and ingests all the unprocessed CSV blobs into a custom Log Analytics table (content type specific). To keep track of the CSV and number of CSV lines already processed, this runbook depends on a SQL Database, where it also gets details about the custom Log Analytics table corresponding to each  CSV type.
  • Deploy-AzureAutomationEngine.ps1 – full deployment script which kicks off the ARM template deployment and sets up the SQL Database at the end.

 

So, to deploy the AOE, you just need to run the Deploy-AzureAutomationEngine script in an elevated prompt and authenticating to Azure with a user account having Owner permissions over the chosen subscription and enough privileges to register Azure AD applications (see details). You’ll be asked several details about your deployment options, including whether you want to reuse an existing Log Analytics workspace or start with a new one.

 

The deployment will take some minutes to complete and you’ll then be asked to enter a password for the Run As certificate for the Automation account. A couple of minutes more and the script will hopefully terminate successfully. In the event of an error, you can re-deploy with the same parameters, as the process is idempotent. You can check the Automation Account schedules created by the deployment (see picture below), which will trigger in a matter of a 1-2-hour timeframe.

 

augmenting-azure-advisor-co-pt2-figure2.jpg

 

Some minutes after all the ingestion runbooks run, you’ll be able to query in Log Analytics for those tables. We’ll make use of these records to generate our recommendations.

 

augmenting-azure-advisor-co-pt2-figure3.jpg

 

Once successfully deployed, and assuming you have your VMs onboarded to Log Analytics and collecting all the required performance counters, we have everything that is needed to start augmenting Advisor recommendations and even generate custom ones! Let it boil for some weeks and keep tuned – in the next post, we’re discussing how AOE produces the actual recommendations and we’ll going to finally see some light! :lol: