MS Azure: VM auto start/shutdown - azure

Is there any way in which I can automate stopping my VM on a Friday and starting this back up again on the Sunday evening at specified times?
I’m aware this is possible via the VM blade and DevTest labs but their only option is daily, whereas I want this only shut down in the weekends.
Any input will be greatly appreciated. Thanks

Given that you need more precise control over scheduling than is possible in the Azure VM Auto-Shutdown blade or Azure Dev-Test Labs, you can accomplish startup / shutdown on specific days via RunBooks in an Azure Automation Resource.
Create (or choose an existing) Azure Automation Account resource
In the new Automation resource, go to the Runbooks blade
Click "Browse Gallery"
Search for and import "Stop Azure V2 VMs" and "Start Azure V2 VMs" runbooks
Schedule the new runbooks to run as needed
This walkthrough shows how to setup your runbooks with a specific schedule and parameters to target your virtual machine(s).

I would recomment to you, to read this:
http://azurecorner.com/start-stop-windows-azure-vms-according-time-schedule/

Related

How to Auto Shut Down Azure Classic VM?

We are using an Azure Classic Virtual Machine!! It does not show 'AutoShutDown' Blade. Is this feature not available for Classic VM? When I searched, there is also an option to use Runbook in Automation Account to do this. Is anyone used this with classic VM?
This feature is not available with classic vms. its 2019, you should migrate to ARM anyway. but you could use custom powershell runbook to shutdown classic vms using a schedule.
you'd need to tag the resource groups (cant tag classic resources) and invoke the runbook hourly. this would be a nice starting point. in fact it does what you ask for.

Azure shut down schedule

We have a client who runs Dynamics NAV infrastructure on Azure VM. I am about to configure a schedule in such a way,it matches office hours.
What will happen if service is used at shutdown time and other user interacting with the service running on VM. Is there a way to manage that?
Thank you.
I am about to configure a schedule in such a way,it matches office
hours.
You could use Azure runbook to schedule start or stop your VM, please refer to this blog.
What will happen if service is used at shutdown time and other user
interacting with the service running on VM.
If your VM shutdown, Dynamics NAV could not provide service. If your user need Dynamics NAS service, you need start your VM.

Scheduling startup (booting) of a Azure VM

I have a Windows based VM on Azure Cloud. Using the Portal on portal.azure.com I can start/stop the machine.
Is there a way to create a schedule in Azure so that the VM is started (booting) on a specific date/time / schedule? So that the VM's state is changed from Stopped (deallocated) to Running when it is scheduled to do so?
You can schedule any operations with Azure Automation.
This article describes how to run Azure VMs during office hours.

How to automate Azure Site Recovery failover?

I have started exploring Azure Site Recovery with VMware as a disaster recovery solution for our customers. The main doubt I have is on how to automate failovers. I.e. how can I tell Azure to check if an on-prem VM is offline and automatically initiate the failover process? Do I need something like OMS to make it happen or should Automation runbooks or something similar be enough?
OMS does not have the solution to automate. But, automation runbooks like you guessed are supported by ASR. However you cannot use automation for individual VM's per se. You can use automation on recovery plans and have one VM as part of that plan.
This should give you some insight.
[1]: https://azure.microsoft.com/en-us/documentation/articles/site-recovery-runbook-automation/

Azure - invoke runbook after VM is created

How do i invoke a Runbook after a VM is created from the portal? I do not see any way to set the trigger and assign a Runbook to it?
If this is not possible, how do i achieve this?
There is currently no direct way to say a runbook should be started after a VM is created, from the portal. This can be done if deploying the VM via an ARM template though, as the ARM template can declare that a runbook job should be started after the VM has been created.
In terms of a portal-based way, you could create a runbook and have it run on a schedule, polling for new VMs to take some action against, as BenV says. Or you could create a webhook for the runbook you want to start, and use the Custom Script Extension in your VM to start that webhook. Since the custom script will run once the VM is created, the runbook will be started after the VM is created.

Resources