Azure Digital Machines – Superior



On this article, we’re going by way of some superior functionalities as a way to take most benefit of your Azure Digital Machines. Every superior performance comes with a sensible pattern and we’re going by way of it, 

  1. Configuring the Availability Set of your Digital Machine, as a way to increase the provision as much as 99.99% uptime assured by SLA;
  2. Executing PowerShell script into your Digital Machine, by way of the Run Command;
  3. Easy methods to migrate current VHDs, to run on Azure Digital Machines;  

With a purpose to perceive higher this text, please verify my earlier article explaining the fundamentals of Azure Digital Machines,

Handle the provision of your Azure VMs


To benefit from Azure 99,99% uptime assured SLA you will need to take some steps as follows,


Availability units


Availability units can defend you from:

  1. System Reboots, to use updates;
  2. {Hardware} failures;
  3. Community issues;
  4. Lack of vitality.

However… how?


One availability set accommodates a set of replace domains and fault domains that run in the identical datacenter.


Replace domains are the place redundancy is utilized to keep away from a system reboot to impression all of your Digital Machines, in the identical replace area group, as a result of updates within the Azure platform.


Fault domains are the place redundancy is utilized to keep away from faults({hardware}, vitality or community issues) on {hardware} or software program to impression all of your Digital Machines operating in the identical fault area group.


When deploying Digital Machines right into a single Availability Set, the Availability Set goes to distribute your VMs mechanically among the many Fault & Replace Domains as follows: 



Availability Zones


Availability Zones are Availability Units operating in several datacenter areas in the identical Azure Area. It implies that they’re bodily separated inside one another, stopping knowledge middle failures and elevating the assured uptime SLA to 99.99%.`


Azure Virtual Machines - Advanced


Azure managed disks 


Azure Managed Disks are bodily disks however virtualized. It brings a number of advantages to your Digital Machine as follows:

  • Extremely accessible, is designed to have 99,999% uptime having three replicas of your knowledge;
  • Extremely sturdy, having a 0% failure price;
  • Built-in with Availability Units, to keep away from single level failure;
  • Scalability, having the ability to deploy as much as 1.000 VMs per scale set;
  • Azure Backup, managing  and scheduling your backups;
  • Direct add, being simpler to deal with your disk knowledge.


Handle OS Upgrades with scheduled occasions


With Scheduled Occasions, chances are you’ll plan for Digital Machine upkeep as a way to keep away from any impression in your shoppers and providers so far as your Digital Machine might want to go down for some time.


Metadata Service API

  • If in case you have VNet in your Digital Machine enabled, that is the endpoint at at this time’s date,
  • For Digital Machines with out VNet enabled, you will need to comply with this tutorial to find your endpoint,

Samples for Querying the API


You have to make these calls out of your Digital Machine PowerShell


Request for Occasions:

  1. $metadataEndpoint = ‘’ 
  3. Invoke-RestMethod -Headers @{“Metadata”=“true”} -URI $metadataEndpoint -Technique get  
Beginning an Occasion:

  1. $metadataEndpoint = ‘’  
  3. Invoke-RestMethod -Uri $metadataEndpoint -Headers @{“Metadata”=“true”} -Technique POST -Physique ‘{“StartRequests”: [{“EventId”: “<your event id goes here>”}]}’  

Enabling and disabling Scheduled Occasions

  • Enabled mechanically after making a request to the Metadata Service API;
  • Disabled mechanically after not making any request to the Metadata Service API for 24 hours.

P.S: Scheduled occasions aren’t accessible in each Azure Area, verify area availability:


Utilizing a Load Balancer to distribute incoming calls 


The Load Balancer is a good software to distribute your incoming request by way of your Digital Machines as a way to don’t overload any Digital Machine, distributing requests amongst your accessible Digital Machines in accordance with your wants.


Well being Probe


Well being probes are going to always run a well being verify, based mostly on configurations set by you, in opposition to your VMs as a way to set your VMs to be accessible or unavailable to obtain requests.



Load Balancer Guidelines 


We create guidelines within the Load Balancer to outline how the incoming site visitors move goes to be distributed among the many accessible Digital Machines. You may additionally configure if you’d like a Well being Probe operating together with your rule as a way to don’t distribute incoming site visitors to your unhealthy VMs.



Utility Tiers


Purposes that make utilization of their software program structure being grouped in tiers might benefit from Utility Tiers, as a way to group your tiers in a special group of Digital Machines. So that you’re capable of separate your software tiers in several availability zones or availability units.


A great observe can be to have every tier of your software in a special Utility Tier and having every Utility Tier in a special Availability Set/Zone. Remembering that an Availability Set/Zone works higher with a number of Digital Machines.


Azure Virtual Machines - Advanced windows/manage-availability


Working PowerShell scripts in your Azure Home windows VM


Chances are you’ll use the Run Command characteristic to run PowerShell instructions remotely by your VM Agent in your Digital Machine. It presents a quick and secure approach to run instructions in your Digital Machine as a way to diagnose, troubleshoot and remediate points which can be affecting your VM.


Out there instructions to run by way of the run command:

  • RunPowerShellScript, the place chances are you’ll run your customized script;
  • EnableRemotePS, enabling your VM to simply accept distant PowerShell instructions;
  • EnableAdminAccount, enabling admin account;
  • IPConfig, working as regular IPConfig command; 
  • RDPSettings, exhibiting registry and area coverage settings;
  • ResetRDPCert, eradicating SSL certificates and resetting your RDP listener;
  • SetRDPPort, setting the port quantity for Distant Desktop Entry. 

Working scripts remotely has some limitations, as Microsoft describes:

  • Script Output is restricted to the final 4,096 bytes.
  • The minimal time to run a script is about 20 seconds.
  • Scripts run as System on Home windows.
  • One script at a time can run.
  • Scripts that immediate for info (interactive mode) aren’t supported.
  • You’ll be able to’t cancel a operating script.
  • The utmost time a script can run is 90 minutes. After that, it’ll trip.
  • Outbound connectivity from the VM is required to return the outcomes of the script.


Migrating current VHDs to Azure VM

If in case you have an current VHD and desires emigrate to Azure Digital Machine you possibly can migrate it with none downside utilizing PowerShell, as follows:


Variables used round code,

  1. $diskName= “sampleDisk”  
  2. $diskLocalPath=“C:myFolderdisk.vhd”  
  3. $imageName=“sampleImage”  
  4. $location= “yourLocation”  
  5. $resourceGroup= “sampleResourceGroup”  
  6. $virtualMachineName=“sampleVm”  

Add your VHD,

  1. #grants a short-term write entry  
  2. $diskTempAccess = Grant-AzDiskAccess -ResourceGroupName $resourceGroup -DiskName $diskName -DurationInSecond 86400 -Entry ‘Write’  
  4. #copy your disk  
  5. AzCopy.exe copy $diskLocalPath  $diskTempAccess.AccessSAS –blob-type PageBlob  

Create an Picture out of your VHD,

  1. $disk = Get-AzDisk -ResourceGroupName $resourceGroup -DiskName $diskName  
  4. $imageConfig = New-AzImageConfig   
  5.    -Location $location  
  6. $imageConfig = Set-AzImageOsDisk   
  7.    -Picture $imageConfig   
  8.    -OsState Generalized   
  9.    -OsType Home windows   
  10.    -ManagedDiskId $disk.Id  
  12.    $picture = New-AzImage   
  13.    -ImageName $imageName   
  14.    -ResourceGroupName $resourceGroup   
  15.    -Picture $imageConfig  

Create a brand new Digital Machine utilizing the copy of your VHD,

  1. New-AzVm `  
  2.     -ResourceGroupName $resourceGroup   
  3.     -Identify $virtualMachineName  
  4.     -Picture $picture.Id   
  5.     -Location $location   
  6.     -VirtualNetworkName “your Vnet”   
  7.     -SubnetName “your subnet”   
  8.     -SecurityGroupName “your safety group”   
  9.     -PublicIpAddressName “your ip”   
  10.     -OpenPorts 3389  

Full code

  1. $diskName= “sampleDisk”  
  2. $diskLocalPath=“C:myFolderdisk.vhd”  
  3. $imageName=“sampleImage”  
  4. $location= “yourLocation”  
  5. $resourceGroup= “sampleResourceGroup”  
  6. $virtualMachineName=“sampleVm”  
  9. #add ——————————————————  
  10. #grants a short-term write entry  
  11. $diskTempAccess = Grant-AzDiskAccess -ResourceGroupName $resourceGroup -DiskName $diskName -DurationInSecond 86400 -Entry ‘Write’  
  13. #copy your disk  
  14. AzCopy.exe copy $diskLocalPath  $diskTempAccess.AccessSAS –blob-type PageBlob  
  17. #create customized picture  —————————————–  
  18. $disk = Get-AzDisk -ResourceGroupName $resourceGroup -DiskName $diskName  
  21. $imageConfig = New-AzImageConfig   
  22.    -Location $location  
  23. $imageConfig = Set-AzImageOsDisk   
  24.    -Picture $imageConfig   
  25.    -OsState Generalized   
  26.    -OsType Home windows   
  27.    -ManagedDiskId $disk.Id  
  29.    $picture = New-AzImage   
  30.    -ImageName $imageName   
  31.    -ResourceGroupName $resourceGroup   
  32.    -Picture $imageConfig  
  35. #create VM  
  36. New-AzVm `  
  37.     -ResourceGroupName $resourceGroup   
  38.     -Identify $virtualMachineName  
  39.     -Picture $picture.Id   
  40.     -Location $location   
  41.     -VirtualNetworkName “your Vnet”   
  42.     -SubnetName “your subnet”   
  43.     -SecurityGroupName “your safety group”   
  44.     -PublicIpAddressName “your ip”   
  45.     -OpenPorts 3389  

Exterior References

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button