{"id":3929,"date":"2022-08-11T07:26:26","date_gmt":"2022-08-11T06:26:26","guid":{"rendered":"https:\/\/www.lieben.nu\/liebensraum\/?p=3929"},"modified":"2022-08-11T07:26:26","modified_gmt":"2022-08-11T06:26:26","slug":"using-an-automation-account-for-azure-automated-right-sizing","status":"publish","type":"post","link":"https:\/\/lieben.nu\/liebensraum\/2022\/08\/using-an-automation-account-for-azure-automated-right-sizing\/","title":{"rendered":"Using an automation account for Azure Automated Right Sizing"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The recommended method to run my <a href=\"https:\/\/www.lieben.nu\/liebensraum\/2022\/05\/automatic-modular-rightsizing-of-azure-vms-with-special-focus-on-azure-virtual-desktop\/\" data-type=\"post\" data-id=\"3870\">ADDRS<\/a> on a schedule is through an Azure Runbook or an Azure DevOps pipeline. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This post describes how to configure an Automation Account to run ADDRS in detailed steps.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><a rel=\"noreferrer noopener\" href=\"https:\/\/portal.azure.com\/#create\/Microsoft.ResourceGroup\" target=\"_blank\">Create a resourcegroup<\/a>:<\/li><\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"714\" height=\"286\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image.png\" alt=\"\" class=\"wp-image-3930\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image.png 714w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-300x120.png 300w\" sizes=\"auto, (max-width: 714px) 100vw, 714px\" \/><\/a><figcaption class=\"wp-element-caption\">create addrs resource group<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">2. <a rel=\"noreferrer noopener\" href=\"https:\/\/portal.azure.com\/#create\/Microsoft.AutomationAccount\" target=\"_blank\">Create an automation account<\/a> in the resource group you just created:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"736\" height=\"498\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-1.png\" alt=\"\" class=\"wp-image-3931\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-1.png 736w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-1-300x203.png 300w\" sizes=\"auto, (max-width: 736px) 100vw, 736px\" \/><\/a><figcaption class=\"wp-element-caption\">create addrs automation account<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">3. Use system assigned managed identity<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"721\" height=\"274\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-2.png\" alt=\"\" class=\"wp-image-3932\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-2.png 721w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-2-300x114.png 300w\" sizes=\"auto, (max-width: 721px) 100vw, 721px\" \/><\/a><figcaption class=\"wp-element-caption\">use system assigned managed identity<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">4. Accept further defaults and when created click Go to resource:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"385\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-3.png\" alt=\"\" class=\"wp-image-3933\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-3.png 643w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-3-300x180.png 300w\" sizes=\"auto, (max-width: 643px) 100vw, 643px\" \/><\/a><figcaption class=\"wp-element-caption\">go to resource ADDRS<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">5. Under the Identity option, click Azure Role Assignments:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"755\" height=\"847\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-5.png\" alt=\"\" class=\"wp-image-3935\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-5.png 755w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-5-267x300.png 267w\" sizes=\"auto, (max-width: 755px) 100vw, 755px\" \/><\/a><figcaption class=\"wp-element-caption\">Go to azure role assignments<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">6. Be sure to select the same subscription your Virtual Machines are in:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1489\" height=\"1013\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-6.png\" alt=\"\" class=\"wp-image-3936\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-6.png 1489w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-6-300x204.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-6-1024x697.png 1024w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-6-768x522.png 768w\" sizes=\"auto, (max-width: 1489px) 100vw, 1489px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">7. If you wish to scope permissions more specifically (always recommended), at minimum you&#8217;ll need to assign Virtual Machine Contributor to the resource group(s) containing your VM&#8217;s and Log Analytics Reader on your log analytics workspace.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">8. Now create a runbook in your new automation account:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"589\" height=\"583\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-7.png\" alt=\"\" class=\"wp-image-3937\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-7.png 589w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-7-300x297.png 300w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/a><figcaption class=\"wp-element-caption\">create runbook<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"719\" height=\"464\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-8.png\" alt=\"\" class=\"wp-image-3938\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-8.png 719w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-8-300x194.png 300w\" sizes=\"auto, (max-width: 719px) 100vw, 719px\" \/><\/a><figcaption class=\"wp-element-caption\">select runbook type and click Create<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">9. After clicking Create, copy paste the following example code in the editor and uncomment either set-rsgRightSize or set-vmRightSize depending on which way you&#8217;re using the module. <a href=\"https:\/\/www.lieben.nu\/liebensraum\/2022\/05\/automatic-modular-rightsizing-of-azure-vms-with-special-focus-on-azure-virtual-desktop\/\" target=\"_blank\" rel=\"noreferrer noopener\">Update the RSG or VM name you&#8217;re targetting and update the workspaceId<\/a><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: powershell; first-line: 1; highlight: [3,5]; title: ; notranslate\" title=\"\">\nConnect-AzAccount -Identity\n\n#set-rsgRightSize -targetRSG \"rg-avd-01\" -workspaceId \"7ccd0949-2fd4-414e-b58c-c013cc6e445d\"\n\n#set-vmRightSize -targetVMName \"azvm01\"  -workspaceId \"7ccd0949-2fd4-414e-b58c-c013cc6e445d\"\n\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">10. Save &amp; Publish<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">11. Go to modules and click browse gallery, search for ADDRS:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"790\" height=\"782\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-9.png\" alt=\"\" class=\"wp-image-3939\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-9.png 790w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-9-300x297.png 300w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-9-768x760.png 768w\" sizes=\"auto, (max-width: 790px) 100vw, 790px\" \/><\/a><figcaption class=\"wp-element-caption\">browse PS gallery for modules<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"286\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-10.png\" alt=\"\" class=\"wp-image-3940\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-10.png 667w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-10-300x129.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/a><figcaption class=\"wp-element-caption\">Search for ADDRS<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"504\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-12.png\" alt=\"\" class=\"wp-image-3942\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-12.png 602w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-12-300x251.png 300w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/a><figcaption class=\"wp-element-caption\">Select ADDRS<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"518\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-13.png\" alt=\"\" class=\"wp-image-3943\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-13.png 727w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-13-300x214.png 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/a><figcaption class=\"wp-element-caption\">Select runtime v 7.1 and import<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">12. Wait for the import to complete. If it fails, check if you have installed the 7.1 versions of these requires modules, install if needed and try again: <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Az.Compute<\/li><li>Az.OperationalInsights<\/li><li>Az.Resources<\/li><li>Az.Accounts<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">13. Run the runbook to test, or link it to a schedule:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-14.png\"><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"398\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-14.png\" alt=\"\" class=\"wp-image-3949\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-14.png 667w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-14-300x179.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/a><figcaption class=\"wp-element-caption\">link runbook to a new schedule<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-15.png\"><img loading=\"lazy\" decoding=\"async\" width=\"523\" height=\"288\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-15.png\" alt=\"\" class=\"wp-image-3950\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-15.png 523w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-15-300x165.png 300w\" sizes=\"auto, (max-width: 523px) 100vw, 523px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"769\" height=\"981\" src=\"https:\/\/www.lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-16.png\" alt=\"\" class=\"wp-image-3951\" srcset=\"https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-16.png 769w, https:\/\/lieben.nu\/liebensraum\/wp-content\/uploads\/2022\/08\/image-16-235x300.png 235w\" sizes=\"auto, (max-width: 769px) 100vw, 769px\" \/><\/a><figcaption class=\"wp-element-caption\">Create a schedule as desired and press create.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">14. if you want to use a schedule different from weekly, make sure to also  add the -measurePeriodHours parameter to match, and if you use maintenance windows, include those as well <a href=\"https:\/\/www.lieben.nu\/liebensraum\/2022\/05\/automatic-modular-rightsizing-of-azure-vms-with-special-focus-on-azure-virtual-desktop\/\" data-type=\"post\" data-id=\"3870\">as described in the module manual.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The recommended method to run my ADDRS on a schedule is through an Azure Runbook or an Azure DevOps pipeline. This post describes how to configure an Automation Account to run ADDRS in detailed steps. Create a resourcegroup: 2. Create an automation account in the resource group you just created: 3. Use system assigned managed &hellip; <a href=\"https:\/\/lieben.nu\/liebensraum\/2022\/08\/using-an-automation-account-for-azure-automated-right-sizing\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Using an automation account for Azure Automated Right Sizing<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[4,5,6,39],"tags":[],"class_list":["post-3929","post","type-post","status-publish","format-standard","hentry","category-automation","category-azure","category-windows-virtual-desktop","category-powershell"],"_links":{"self":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/3929","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/comments?post=3929"}],"version-history":[{"count":0,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/posts\/3929\/revisions"}],"wp:attachment":[{"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/media?parent=3929"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/categories?post=3929"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lieben.nu\/liebensraum\/wp-json\/wp\/v2\/tags?post=3929"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}