-1

In order to save expenses in Azure DevOps, I'm trying to scale the resources, which can scale depending on the requirement. Team leads will update the resource requirements in SharePoint, and the runbook needs to be executed with SharePoint datat. Team leads will update the resource requirements in SharePoint, and the runbook needs to be executed with SharePoint data. If such resources are not required on weekends but must be operational on weekdays, they should be stopped or reduced in size. I need to use automation to do it for all of the VMs and App Services at a subscription level every Friday. If there is a method to automate this procedure using PowerShell.

I'm glad to receive input. Thanks in advance. I'm looking for feedback on Start/Stop VMs and Scaling Azure App Services. On weekends, the same may be said for other relevant resources. How can we accomplish this with Azure PowerShell?  

Kai
  • 11
  • 2
Dwara
  • 9
  • 2
  • you could create a scheduled pipeline using a cron expression (https://learn.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers?view=azure-devops&tabs=yaml) which has a powershell task that does all of your desired shutting down (https://learn.microsoft.com/en-us/powershell/module/az.compute/stop-azvm?view=azps-9.2.0#examples) ? – classicSchmosby98 Dec 15 '22 at 14:20

2 Answers2

-1

The best way to do is by using 'Azure Automation Runbook' scheduled to run every specified day or date by time. To target the VM's, Azure Tags will be much helpful. Your script must check:

  1. A VM has a specific Tags (e.g., StopVM:Friday 11:00PM)
  2. Maintenance Enabled in your monitoring solution
  3. VM is stopped already or not.
  4. Backup required?
  5. Confirm the VM is Deallocated (not stopped)

Auto-Shutdown option is also available to do this activity.

Dilly B
  • 1,280
  • 2
  • 11
  • 15
-1

Because sometime all you need is a quick and dirty way to save money :

enter image description here

And if you wan't to build something there's an API to shutdown and start VMs

Will
  • 1,792
  • 2
  • 23
  • 44
  • Thank you for your helpful response. I need to use automation to do it for all of the VMs and App Services. Every Friday, team leads will update the resource requirements in SharePoint, and this RunBook will need to execute with the use of that data. – Dwara Dec 15 '22 at 16:14
  • @Dwara , what kind of work are you doing where the team leads will know in advance if a cloud service is needed over the weekend, but it will also change on a week-by-week basis? I'm just curious. Seems an unusual requirement. – Zach Dec 15 '22 at 16:21
  • @Zach Yes, As you mentioned resource requirements will ,change on week-by-week. We are getting the confirmation from respective team. for that we plan to use SharePoint. – Dwara Dec 15 '22 at 16:33
  • @Zach SharePoint list was basically used for exclusion and tagging resources. It had below columns: i. Resource Name ii. checkbox for Weekday exclusion iii. checkbox for Weekend exclusion iv. Date (till which said resource will be excluded from the script/auto shutdown v. Reason/Business Justification – Dwara Dec 15 '22 at 16:37