Azure – You can now deploy Azure Monitor Application Insights Agent on Azure Virtual machine and Azure Virtual Machine Scale Sets

You may already know Azure Monitor Application Insights, which is an application performance management service for web developers, helping you gain insights about your application performance and reliability.

Well, good news, you can now deploy Azure Monitor Application Insights as an agent (aka extension) on Azure Virtual Machines or Azure Virtual Machines Scale Sets when these VM/Scale Sets host web application running on .Net with IIS (if you are using another language you still need to use the SDK to embedded Application Insights into your application).

This can be quite useful when you do not have access to the source code of the application and want to leverage and take advantage of Application Insights.

You have 2 ways to deploy the Application Insights agent on your VM/Scale Sets:

  • From the Azure portal ( by accessing the Extension blade of your virtual machine/scale sets and add the Application Insights Agent extension

For Virtual Machine

image  image  image

For Virtual Machine Scale Sets

image  image  image

  • Of using PowerShell by using the following command

For a virtual machine

$publicCfgJsonString = ‘
   “redfieldConfiguration”: {
     “instrumentationKeyMap”: {
       “filters”: [
           “appFilter”: “.*”,
           “machineFilter”: “.*”,
           “instrumentationSettings” : {
             “instrumentationKey”: “<instrumentation key from your Application Insights”
$privateCfgJsonString = ‘{}’;

Set-AzVMExtension -ResourceGroupName “<your resource group>” -VMName “<your virtual machine>” -Location “<location of the virtual machine>” -Name “ApplicationMonitoring” -Publisher “Microsoft.Azure.Diagnostics” -Type “ApplicationMonitoringWindows” -Version “2.8” -SettingString $publicCfgJsonString -ProtectedSettingString $privateCfgJsonString

For a virtual machine scale sets

$publicCfgHashtable =
   “redfieldConfiguration”= @{
     “instrumentationKeyMap”= @{
       “filters”= @(
           “appFilter”= “.*”;
           “machineFilter”= “.*”;
           “instrumentationSettings”= @{
             “instrumentationKey”= “<instrumentation key from your Application Insights”
$privateCfgHashtable = @{};

$vmss = Get-AzVmss -ResourceGroupName “<your resource group>” -VMScaleSetName “<your VM Scale Sets name>”

Add-AzVmssExtension -VirtualMachineScaleSet $vmss -Name “ApplicationMonitoring” -Publisher “Microsoft.Azure.Diagnostics” -Type “ApplicationMonitoringWindows” -TypeHandlerVersion “2.8” -Setting $publicCfgHashtable -ProtectedSetting $privateCfgHashtable

Update-AzVmss -ResourceGroupName $vmss.ResourceGroupName -Name $vmss.Name -VirtualMachineScaleSet $vmss

Leave a Comment

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

The reCAPTCHA verification period has expired. Please reload the page.