Auto-Stop Virtual Machines based on CPU utilization

 

Auto-Stop Virtual Machines based on CPU utilization:

Microsoft Azure provides a service to Start or stop virtual machines (VMs) whenever there is more/less load of CPU utilization.

  Prerequisites to test the Auto shutdown based on CPU utilization:

  • A resource group containing the VMs

  • An automation account with an azure run as account

  • An azure monitor log analytics workspace

Go to Home> "Start/Stop VMs during off hours" > Create

Click on Add Solution> Create New Workspace > Fill-up the details > Create.

Click on Automation Account> Create an Automation Account> Ok

Click on Configuration> Parameters >Fill-up the  required details.

You can mention * to include for all resource group as target resource group and none to include all VM’s .

 In this case we mentioned a resource group.To exclude any VM’s mention the VM Name with comma separated values.

Mention the Start and Stop schedule of the VM’s and configure mail id for notification >Ok 

https://i0.wp.com/azurebro.com/wp-content/uploads/2019/06/azure-portal-add-solution-01.png?resize=313%2C514&ssl=1

Go to  Automation Account > Schedules> Disable the Scheduled-StopVM so that the machine won’t stop as per the schedule

Go to Automation Account > Variables> Search “External_AutoStop”

External_AutoStop_Condition: This is the conditional operator required for configuring the condition before triggering an alert. Possible values are [GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual]

External_AutoStop_Threshold: Threshold for the Azure Alert rule. Possible percentage values ranging from 1 to 100

External_AutoStop_TimeAggregationOperator: The time aggregation operator which will be applied to the selected window size to evaluate the condition. Possible values are [Average, Minimum, Maximum, Total, Last]

External_AutoStop_TimeWindow: The window size over which Azure will analyze selected metric for triggering an alert. This parameter accepts input in timespan format. Possible values are from 5 mins to 6 hours.

For Testing: In this case ,I configured the VMs to stop automatically if the average CPU usage is Less than or equal to 50% for period of 15 Secs.

Go to Automation Account > Schedules, enable and modify the schedule for Schedule_AutoStop_CreateAlert_Parent.

To Review the schedule /running  Jobs :Go to Automation account >Jobs

To Review the VM logs  : Go to VM>Activity logs




                                                 Thank You !!

 

Comments

Popular posts from this blog

AZCopy : Upload and Download files from or to Azure Storage account using AZcopy

AZURE ADMINISTRATOR ASSOCIATE (AZ-104)