The benefits of using Azure WVD are:
- Set up a multi-session Windows 10 deployment that delivers a full Windows 10 with scalability
- Virtualize Microsoft 365 Apps for enterprise and optimize it to run in multi-user virtual scenarios
- Provide Windows 7 virtual desktops with free Extended Security Updates
- Bring your existing Remote Desktop Services (RDS) and Windows Server desktops and apps to any computer
- Virtualize both desktops and apps
- Manage Windows 10, Windows Server, and Windows 7 desktops and apps with a unified management experience
Lots of business now start to migration/deploy the Azure WVD to gain the benefits. However, a common question, typically in the cloud space, has been raised, how to save the cost of the Azure WVD. If we look into the Azure cost breakdown of Azure IaaS, most likely, the 70% cost is for compute, and 20% is for the storage for the disks. So, the quick solution could be to use the scheduled power-on/off activities with azure automation account. This can help to reduce the compute cost in Azure because all these windows virtual desktops will be deallocated and have no cost for compute. Unfortunately, this solution is not really practical because the users might still work after the scheduled power off time, or there are tasks still running inside of these windows virtual desktops. If all the desktops just simply shutdown at the scheduled time, the users will lose the their work.
Since there is no out of box solution yet from Microsoft, a combination of Azure Logical App and Azure Log Analytics can be used to address this need.
Azure Logical App is a cloud service that can help to schedule, automate, and orchestrate tasks, business processes, and workflow when integrate apps, data, systems, and services across enterprises or organizations. Azure Log Analytics is also a cloud service which is able to aggregate VM and Azure resource log files into a single data lake (called a Log Analytics workspace) and then run queries against the data, using a Microsoft-created data access language called Kusto (pronounced KOO-stoh) Query Language (KQL).
The logic behind of this solution is that Azure Logical App will run the Azure log query to determine whether there is any user session in these windows virtual desktop after the scheduled power off time. If there still are sessions in these desktops, keep them running, if not, shutdown the desktops. The following is the diagram of the workflow:
Step 1:
Define the scheduled run of the Azure logical apps
Step 2:
Query the active sessions of each desktop. The following is the sample Azure Log query to return the virtual desktop name (VMList) and the Resource Group the virtual desktop belongs to (ResourceGroup) when total terminal service sessions are less than 2, because if there is user login the virtual desktop, the session number will be more than 2.
Perf
| where ObjectName == "Terminal Services"
| where CounterName == "Total Sessions"
| where TimeGenerated > ago(5m)
| where CounterValue <= 2
| extend CSVFields = split(_ResourceId, '/')
| extend VMList = tostring(CSVFields[8])
| extend ResourceGroup = tostring(CSVFields[4])
Step 3:
Pass the VMlist and Resource Group parameters to Azure Log Apps action Deallocate Virtual Machines.
There are pre-requisites for this solution to work:
1. Azure Log Analytics Workspace and Azure Logical App need be provisioned;
2. The connectors for Azure Log Analytics and Azure VM need be created for Azure Logical App;
3. The performance counter for Terminal Sessions need be added into the Azure Log Analytics Workspace;
4. The Windows Group Policy need be setup to log out the users if inactive for certain period of time.
This solution also can expand to the whole Azure tenancy to shutdown other virtual servers which are dedicated for the Azure WVD, such as domain controllers and network virtual appliances.

Excellent job, this is great information which is shared by you. This info is meaningful and factual for us to increase our knowledge about it. So please always keep sharing this type of information. Accounting Services For Small Business
ReplyDeleteSome genuinely wonderful information, Glad I discovered this. I must say that you’ve done a superb job with this. And I am glad to read your article. Best of luck for the next! Please visit my website. Best Hosted Virtual Desktop Services service provider.
ReplyDelete