Using an automation account for Azure Automated Right Sizing

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.

  1. Create a resourcegroup:
create addrs resource group

2. Create an automation account in the resource group you just created:

create addrs automation account

3. Use system assigned managed identity

use system assigned managed identity

4. Accept further defaults and when created click Go to resource:

go to resource ADDRS

5. Under the Identity option, click Azure Role Assignments:

Go to azure role assignments

6. Be sure to select the same subscription your Virtual Machines are in:

7. If you wish to scope permissions more specifically (always recommended), at minimum you’ll need to assign Virtual Machine Contributor to the resource group(s) containing your VM’s and Log Analytics Reader on your log analytics workspace.

8. Now create a runbook in your new automation account:

create runbook
select runbook type and click Create

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’re using the module. Update the RSG or VM name you’re targetting and update the workspaceId

Connect-AzAccount -Identity

#set-rsgRightSize -targetRSG "rg-avd-01" -workspaceId "7ccd0949-2fd4-414e-b58c-c013cc6e445d"

#set-vmRightSize -targetVMName "azvm01"  -workspaceId "7ccd0949-2fd4-414e-b58c-c013cc6e445d"

10. Save & Publish

11. Go to modules and click browse gallery, search for ADDRS:

browse PS gallery for modules
Search for ADDRS
Select ADDRS
Select runtime v 7.1 and import

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:

  • Az.Compute
  • Az.OperationalInsights
  • Az.Resources
  • Az.Accounts

13. Run the runbook to test, or link it to a schedule:

link runbook to a new schedule
Create a schedule as desired and press create.

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 as described in the module manual.

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
trackback

[…] If you wish to run this automatically on a schedule, I recommend either using an Azure DevOps pipeline or Automation account. I’ve compiled a small guide on how to use ADDRS in an Azure Automation Account. […]