Cost management is an integral part of managing Azure resources, and you can see that under the billing section major portion is covered by Virtual Machines. You can create automated management tasks for a specific resource or resource group by automation task templates, which vary in availability based on the resource type. So, in some cases, you can stop the VMs at specific schedules to save the operations cost of VMs. In this blog, you will get to know how to Start and Stop the VMs on-off office hours and even on weekends and manage your Azure Resources efficiently.
3. Configuring Log Analytics Workspace
1. Log in to the Azure Portal and go to Log Analytics Workspace service and click on create
Note: – Log Analytics Workspace stores the runbook job logs and job stream results in a workspace to query and analyze
2. Now fill the relevant information under Create Log Analytics workspace page and once done in the last, click on Review + Create and then Create
Subscription: choose a valid subscription
Resource group: Select existing or create new
Name: Name for Workspace
Region: region for workspace. Configuring Automation Accounts to Start/Stop VMs
3. Go to Automation Accounts Services and click on Create and fill in the relevant information. After that, click on Next
Subscription: choose a valid subscription
Resource group: Select existing RG same as of workspace
Name: Name for Automation Account
Region: region same as Workspace (Central India)
4. Under the Advanced tab, select the System assigned checkbox and click on Under the Networking tab, select Public access and click on Review + create, and once validation passed, click on Create
5. Once the Automation Account Automation-StartStop-VM gets created, go inside it. Under the Related resources section, select Start/Stop VM and then click on Learn more about and enable the solution6. A new page will open; click on Create under Start/Stop VMs during the off-hours section
7. After clicking on Create an Add Solution page will open, select the Workspace and Select Automation Account created in the above steps, and after that, click on Parameters under the Configuration section.
8. Parameters page will open and fill the relevant information: and click on OK and after that click on Create under Add Solution page
Target Resource Group: Select the VM resource group
VM Exclude List (string): Enter the VM name if you want to exclude anything else. Keep none
Daily Start/ Stop date & time: enter based on requirement
Email functionality: if yes, provide the email Id under Email Addresses.
9. Now go to Automation Account Automation-StartStop-VM, click on Run as accounts under Accounts Settings Section, and click on Create Azure Run as Account. A new page will open. Add Azure Run As Account click on create.(The Run As account feature will create a new service principal user in Azure Active Directory and assign the Contributor role to this user at the subscription level.)
Note: If the account is an Azure AD account, it should have administrator access to perform this action.
B. Configuring Schedules
10. Go to Automation Account Automation-StartStop-VM and select Schedules from the Shared Resources section, and modify schedules by clicking on these highlighted schedules based on the requirement. By default, linked with runbook ScheduledStartStop_Parent required to act once the modification is done click on Save
Note: – you can also set VM to Stop on weekends by choosing the Week option from
Recur every and select days to start and follow the same process for Start VMC. Checking Start/Stop Jobs
11. Under the Jobs section of the Automation Account, you can keep track of logs of schedules in terms of Start/Stop triggered.
In this blog, I have shown you how to Start/Stop VMs on-off office hours, including weekends, and we can also keep track of Start/Stop jobs with easy management. Furthermore, you can schedule the Start/Stop based on your requirement. This will benefit you tremendously by saving the operational cost of the Virtual Machines. And you can make the VM available during working hours only.
CloudThat is the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere. Drop a query if you have any questions regarding Azure Resources, Virtual MAchine Automation, or consulting opportunities, and I will get back to you quickly. To get started, go through ourExpert Advisorypage and Managed Services Package that isCloudThat’s offerings.
1. What is Automation Account?
With an Automation account, you can authenticate runbooks by managing resources in either Azure Resource Manager or the classic deployment model. One Automation Account can manage resources across all regions and subscriptions for a given tenant.
2. What is the use of Log Analytics Workspace?
Log Analytics workspace is the environment for Azure Monitor log data. Each workspace has its data repository and configuration, and data sources and solutions are configured to store their data in a particular workspace.
3. Run as an account in Azure Automation?
Run As accounts in Azure Automation provide authentication for managing resources on the Azure Resource Manager or Azure Classic deployment model using Automation runbooks and other Automation features.