Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Enable Azure Monitor Application Insights monitoring through autoinstrumentation for Internet Information Server (IIS)-hosted ASP.NET and ASP.NET Core applications on Azure Virtual Machines and Azure Virtual Machine Scale Sets. Deploy the Application Insights Agent with a virtual machine extension. The agent autocollects the same dependency signals as the SDK. Use PowerShell to automate large-scale deployments.
Note
- For Java applications, use the Application Insights Java 3.0 agent, which autocollects the most popular libraries, frameworks, logs, and dependencies, along with many other configurations.
- Node.js and Python applications running on Azure VMs and Azure Virtual Machine Scale Sets don't support autoinstrumentation. Use the Azure Monitor OpenTelemetry Distro instead.
- To monitor VM guests in addition to the applications hosted on them, see VM guest data.
For a complete list of supported autoinstrumentation scenarios, see Supported environments, languages, and resource providers.
Prerequisites
Before you install the Application Insights Agent extension, you need a connection string. Create a new Application Insights resource or copy the connection string from an existing one.
Enable monitoring for virtual machines
You can use the Azure portal or PowerShell to enable monitoring for VMs.
In the Azure portal, go to your Application Insights resource. Copy your connection string to the clipboard.
Go to your virtual machine. Under the Settings section in the menu on the left side, select Extensions + applications > Add.
Select Application Insights Agent > Next.
Paste the connection string you copied in step 1 and select Review + create.
instrumentationKeyMap (extension settings)
Important
InstrumentationKeyMap is an advanced routing feature that maps Internet Information Services (IIS) apps on the same machine to Application Insights resources. The feature applies to IIS-hosted ASP.NET and ASP.NET Core apps that the Application Insights Agent autoinstruments.
How matching works
- The map defines an ordered list of rules named
filters
. The first matching rule takes effect. Place specific rules first and finish with a catch-all rule. - Each rule can assign a different Application Insights resource to matching apps. Prefer connection strings in supported scenarios because instrumentation keys are legacy.
Available filters
MachineFilter
ormachineFilter
: C# regular expression that matches the computer or virtual machine (VM) name..*
matches all names.AppFilter
orappFilter
: C# regular expression that matches the IIS site name (HostingEnvironment.SiteName
). This filter is required whenVirtualPathFilter
orvirtualPathFilter
isn't provided.VirtualPathFilter
orvirtualPathFilter
: C# regular expression that matches the IIS virtual path (HostingEnvironment.ApplicationVirtualPath
). Use this filter to target a single app under a site.
Terminology mapping
- PowerShell cmdlets use
MachineFilter
,AppFilter
, andVirtualPathFilter
. - Azure VM and Virtual Machine Scale Sets extension JSON uses
machineFilter
,appFilter
, andvirtualPathFilter
, and sets the resource withinstrumentationSettings
.
Tip
Include a final rule that matches all apps, such as .*
, and apply a default resource to make the behavior explicit.
Where it goes for the VM and Virtual Machine Scale Sets extension
Place the map under redfieldConfiguration.instrumentationKeyMap.filters
in the extension's public settings (-SettingString
for VMs, -Setting
for Virtual Machine Scale Sets). Property names are lower camel case. Set the target resource per rule with instrumentationSettings.connectionString
.
{
"redfieldConfiguration": {
"instrumentationKeyMap": {
"filters": [
{
"machineFilter": ".*",
"appFilter": ".*",
"instrumentationSettings": {
"connectionString": "<your-APPLICATIONINSIGHTS_CONNECTION_STRING>"
}
}
]
}
}
}
Enable monitoring for virtual machine scale sets
You can use the Azure portal or PowerShell to enable monitoring for virtual machine scale sets.
Follow the prior steps for VMs, but go to your virtual machine scale sets instead of your VM.
Troubleshooting
Use these troubleshooting tips for the Application Insights Monitoring Agent extension. The tips apply to .NET applications on Azure Virtual Machines and Azure Virtual Machine Scale Sets.
If you have trouble deploying the extension, review the execution output that the extension logs to files in the following directories:
C:\WindowsAzure\Logs\Plugins\Microsoft.Azure.Diagnostics.ApplicationMonitoringWindows\<version>\
If your extension deployed successfully but you're unable to see telemetry, it could be one of the following issues covered in Agent troubleshooting:
- Conflicting dynamic link libraries (DLLs) in an app's bin directory
- Conflict with IIS shared configuration
Test connectivity between your application host and the ingestion service
Application Insights SDKs and agents send telemetry to get ingested as REST calls to our ingestion endpoints. You can test connectivity from your web server or application host machine to the ingestion service endpoints by using raw REST clients from PowerShell or curl commands. See Troubleshoot missing application telemetry in Azure Monitor Application Insights.
Release notes
2.8.44
- Updated Application Insights .NET/.NET Core SDK to 2.20.1 - red field.
- Enabled SQL query collection.
- Enabled support for Microsoft Entra authentication.
2.8.42
Updated Application Insights .NET/.NET Core SDK to 2.18.1 - red field.
2.8.41
Added the ASP.NET Core autoinstrumentation feature.
Next steps
- To review frequently asked questions (FAQ), see Application Insights for Azure VMs and virtual machine scale sets FAQ
- Deploy your application on Virtual Machine Scale Sets.
- Application Insights availability tests
- Monitor VM guest data