With this blogpost I want to explain how you can connect your existing Azure RemoteApp environment with Azure Operational Insights. Operational Insights is part of the Operations Management Suite and is a cloud monitoring solution which can be used to collect information from different sources. In this blogpost I want to focus on adding a Hybrid Azure RemoteApp collection to OpInsight. In coming blogposts, I will explain what Azure Operational Insights can monitor from the Azure RemoteApp environments.
The first step is to create a OpInsight environment. You can do this by going to this link and create your own free OpInsight environment. When you have your Operational Insights environment you only have to connect clients to this environment. In our scenario we first want to add an Azure RemoteApp environment. My goal is to do this through updating the Master Image. When my collection is updated with this Master Image the instances should be automatically added to Azure Operational Insights. The only problem is that you need to configure the Microsoft Monitoring agent after the deployment of an instance. I have created the following solution which meets my goals of adding instances automatically to Azure OpInsight. Execute the following steps:
- Create a VM with based on your previous Master Image
- Download the Microsoft Monitoring Agent from the OpInsight Portal
- Install the Microsoft Monitoring Agent on your Master Image VM without connecting to an environment.
- After the installation reboot your Master Image VM
- After the reboot stop the ‘Microsoft Monitoring Agent Service’
- Save the following script locally on your Master Image VM. Replace Master VM Name with your own Master VM Computername, workspace id with your own workspace id and replace workspace key with your own workspace key. Script:
if ($env:computername -ne "Master VM Name") { $healthServiceSettings = New-Object -ComObject 'AgentConfigManager.MgmtSvcCfg' $opinsight_enabled = $healthServiceSettings.AzureOperationalInsightsEnabled if( $opinsight_enabled -eq $false) { Write-Verbose "OpInsight will be enabled" #Remove Existing MMA certificates Get-ChildItem -Path 'Cert:\LocalMachine\Operations Manager' | Remove-Item #Enable OpInsight on MMA $healthServiceSettings.EnableAzureOperationalInsights('workspace id', 'workspace key') $healthServiceSettings.ReloadConfiguration() #Restart the MMA Restart-Service -Name 'HealthService' Write-Verbose "OpInsight is enabled" } else { Write-Verbose "OpInsight is already enabled" } }
- The next step is to put the above script in a scheduled task. Configure the scheduled task as follows:
- On the first screen give it a name and description
- As trigger use ‘At System Startup’
- As Action use the following
Program/Script: C:\Windows\System32\windowspowershell\v1.0\powershell.exe
Arguments: -Command “& C:\_install\configure_mmaagent.ps1” - In the properties of the task change the Run As user tot ‘SYSTEM’ and check the following checkbox: ‘Run with highest privileges’
- The next step is to prepare the ConfigMgr client for imaging. The following actions need to be executed:
- Stop the ‘SMS Agen Host’ Service.
- Delete the ConfigMgr certificates from the Local Machine Certificate store.
- Remove the %SYSTEMROOT%\SMSCFG.ini file.
- The last step is to execute SysPrep by running the following command:
C:\Windows\System32\sysprep\sysprep.exe /generalize /oobe /shutdown
Next step is to upload the new Master Image into Azure RemoteApp. When the image is uploaded apply this new update to your Azure RemoteApp collection. When the updates process is finished you should see that the instances will be added to your Operational Insights environment:
You can check if the Microsoft Monitoring Agent is working as it should by checking the eventlog of an Azure RemoteApp instance and look into the Operations Manager eventlog for the event:
In the second part of this blogseries I want to focus on adding solutions to the Operational Insights environment which are usable in an Azure RemoteApp scenario.
If you have any questions please let me know!
Where does the .AzureOperationalInsightsEnabled managment group come from for this script? I cant seem to find it in my standard azure image
Hi Jason,
Sorry for my late reply. You first need to install the Microsoft Monitoring Agent. When installed you can create the ComObject and use .AzureOperationalInsightsEnabled. Please drop me an email if you need more help.
Regards, Arjan