Forum Discussion
Azure Virtual Desktop
Hi Thanks for your response I have tried this option, but it only shut it down on specific time which I have already enabled but what I am looking here is when machine is idea for 15 or 30 min and no user is connected it need to be shut down and deallocated automatically.
Is this an option?
Many Thanks
To automatically shut down and deallocate your Azure Virtual Desktop after 15–30 minutes of inactivity, please try these steps
1. Enable Diagnostics: Log user sessions to a Log Analytics Workspace.
Go to the Azure Virtual Desktop blade in the Azure portal.
Navigate to Host Pools > Diagnostics Settings.
Enable diagnostics to capture user session information. Send logs to a Log Analytics Workspace.
2. Use Automation: Create an Azure Automation Runbook that queries session activity from Log Analytics.
3. Set Idle Logic: If no users are connected for the defined period, the Runbook stops and deallocates the VM.
Go to Azure Automation Accounts and create a new account.
Add the Az.Compute and Az.OperationalInsights modules.
Create a Runbook and paste the script above.
Test the script to ensure it works correctly.
Create a schedule or trigger for the Runbook to execute every 15–30 minutes.
Great Thought!. This ensures cost-efficiency and seamless management.