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.
2. Create an automation account in the resource group you just created:
3. Use system assigned managed identity
4. Accept further defaults and when created click Go to resource:
5. Under the Identity option, click 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:
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:
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:
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.
[…] 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. […]