Start Stop Multiple Azure VMs on schedule using Azure Automation
Abs07act
I searched through many, many, many…articles written
about Azure VM stop(de-allocate) to save cost. Every article only targets
single Azure VM to shutdown (de-allocate). None of the articles target start
and Shutdown of multiple Azure VMs using automation. I am going to address this
using Azure powershell in this article.
If you have multiple Azure VMs present in your azure
subscription; and you want to start or stop few of them on schedule then you
can use below azure PowerShell scripts. It will have below features –
è Add/
remove the VM names from the list of start/ stop schedule easily. [You don’t
need to have PowerShell knowledge]
è Use
same script in multiple different Azure runbooks, with different Azure VM names
to start and stop; that too with different schedules.
è In
case any wrong/ nonexistent VM name added to the list, script takes care of
giving relative user-friendly message and do not throw error. It continues with
other remaining set of Azure VMs and perform start or stop.
è Can
be used with single VM as well if required.
è You
start and stop azure VMs based on schedule hence obviously you optimize or save
Azure cost.
è Script
is available for download; hence you can own it to change in future. [that’s
cool 😊]
I can say all above feature are nothing but the “Key
differentiator” or “Value Proposition” from other Azure VM shut down/ start
automation blogs/ scripts. [These marketing terms; I hear them a lot 😊]
Azure VM are made of Compute and Storage. Compute is
nothing but Core (number of cores/ CPUs) and RAM you get when you provision
Azure VM. Storage is nothing but the C drive or other letter drives; except D
drive for windows and Sdb drive for Linux]. These drives are nothing but disks
or .vhd files present in Azure storage account [if VM is unmanaged] else disks
or .vhd files will be part of your subscription [if VM is created using managed
disks].
When we say you stop Azure VM from portal or using
PowerShell command “Stop-AzureRMVm” basically Compute part of VM is released
(or de-allocated). It is worth to mention here that “STORAGE PART REMAINS”.
So, when you think that if VM is in de-allocated state
then I am not charged, YOU ARE WRONG. You are not charged for compute/Cores
part; for storage capacity you are charged. However that is too cheap, so don’t
worry. Cores are costly and that is where you save cost.
Also if you shutdown Azure VM after taking RDP/ SSH,
compute is not released so you are charged for compute and storage both in that
case. Therefore, it is recommended that you stop azure vm either using portal
or PowerShell command. Refer the FAQ section from link
for more details.
Let’s go back to script part now.
Comments
Post a Comment