- Configuring the Availability Set of your Virtual Machine, in order to raise the availability up to 99.99% uptime guaranteed by SLA;
- Executing PowerShell script into your Virtual Machine, through the Run Command;
- How to migrate existing VHDs, to run on Azure Virtual Machines;
In order to understand better this article, please check my previous article explaining the basics of Azure Virtual Machines,
To take advantage of Azure 99,99% uptime guaranteed SLA you must take some steps as follows,
Availability sets
Availability sets can protect you from:
- System Reboots, to apply updates;
- Hardware failures;
- Network problems;
- Lack of energy.
But... how?
One availability set contains a set of update domains and fault domains that run in the same datacenter.
Update domains are where redundancy is applied to avoid a system reboot to impact all your Virtual Machines, in the same update domain group, due to updates in the Azure platform.
Fault domains are where redundancy is applied to avoid faults(hardware, energy or network problems) on hardware or software to impact all your Virtual Machines running in the same fault domain group.
When deploying Virtual Machines into a single Availability Set, the Availability Set is going to distribute your VMs automatically among the Fault & Update Domains as follows:

Availability Zones
Availability Zones are Availability Sets running in different datacenter locations in the same Azure Region. It means that they are physically separated within each other, preventing data center failures and raising the guaranteed uptime SLA to 99.99%.`

Azure managed disks
Azure Managed Disks are physical disks but virtualized. It brings lots of benefits to your Virtual Machine as follows:
- Highly available, is designed to have 99,999% uptime having 3 replicas of your data;
- Highly durable, having a 0% failure rate;
- Integrated with Availability Sets, to avoid single point failure;
- Scalability, being able to deploy up to 1.000 VMs per scale set;
- Azure Backup, managing and scheduling your backups;
- Direct upload, being easier to handle your disk data.
Manage OS Upgrades with scheduled events
With Scheduled Events, you may plan for Virtual Machine maintenance in order to avoid any impact on your clients and services as far as your Virtual Machine will need to go down for a while.
Metadata Service API
- If you have VNet in your Virtual Machine enabled, this is the endpoint at today's date,
http://169.254.169.254/metadata/scheduledevents?api-version=2019-01-01 - For Virtual Machines without VNet enabled, you must follow this tutorial to discover your endpoint,
https://github.com/azure-samples/virtual-machines-python-scheduled-events-discover-endpoint-for-non-vnet-vm
Samples for Querying the API
You must make those calls from your Virtual Machine PowerShell
Request for Events:
- $metadataEndpoint = 'http://169.254.169.254/metadata/scheduledevents?api-version=2019-01-01'
- Invoke-RestMethod -Headers @{"Metadata"="true"} -URI $metadataEndpoint -Method get
Starting an Event:
- $metadataEndpoint = 'http://169.254.169.254/metadata/scheduledevents?api-version=2019-01-01'
- Invoke-RestMethod -Uri $metadataEndpoint -Headers @{"Metadata"="true"} -Method POST -Body '{"StartRequests": [{"EventId": "<your event id goes here>"}]}'
Enabling and disabling Scheduled Events
- Enabled automatically after making a request to the Metadata Service API;
- Disabled automatically after not making any request to the Metadata Service API for 24 hours.
P.S: Scheduled events are not available in every Azure Region, check region availability:
Using a Load Balancer to distribute incoming calls
The Load Balancer is a great tool to distribute your incoming request through your Virtual Machines in order to do not overload any Virtual Machine, distributing requests among your available Virtual Machines according to your needs.
Health Probe
Health probes are going to constantly run a health check, based on configurations set by you, against your VMs in order to set your VMs to be available or unavailable to receive requests.
We create rules in the Load Balancer to define how the incoming traffic flow is going to be distributed among the available Virtual Machines. You may also configure if you want a Health Probe running with your rule in order to do not distribute incoming traffic to your unhealthy VMs.
Application Tiers
Applications that make usage of their software architecture being grouped in tiers may take advantage of Application Tiers, in order to group your tiers in a different group of Virtual Machines. So you're able to separate your application tiers in different availability zones or availability sets.
A good practice would be to have each tier of your application in a different Application Tier and having each Application Tier in a different Availability Set/Zone. Remembering that an Availability Set/Zone works better with multiple Virtual Machines.
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/manage-availability
Running PowerShell scripts in your Azure Windows VM
You may use the Run Command feature to run PowerShell commands remotely by your VM Agent in your Virtual Machine. It offers a fast and safe way to run commands in your Virtual Machine in order to diagnose, troubleshoot and remediate issues that are affecting your VM.
Available commands to run through the run command:

Join the conversation! Your thoughts help the community grow.