Enable Snapshot Debugger for .NET apps in Azure App Service

Snapshot Debugger currently supports ASP.NET and ASP.NET Core apps that are running on Azure App Service on Windows service plans.

We recommend you run your application on the Basic service tier, or higher, when using snapshot debugger.

For most applications, the Free and Shared service tiers don't have enough memory or disk space to save snapshots.

Enable Snapshot Debugger

To enable Snapshot Debugger for an app, follow the instructions below.

If you're running a different type of Azure service, here are instructions for enabling Snapshot Debugger on other supported platforms:

Note

If you're using a preview version of .NET Core, or your application references Application Insights SDK, directly or indirectly via a dependent assembly, follow the instructions for Enable Snapshot Debugger for other environments to include the Microsoft.ApplicationInsights.SnapshotCollector NuGet package with the application, and then complete the rest of the instructions below.

Codeless installation of Application Insights Snapshot Debugger follows the .NET Core support policy. For more information about supported runtimes, see .NET Core Support Policy.

Snapshot Debugger is pre-installed as part of the App Services runtime, but you need to turn it on to get snapshots for your App Service app.

Once you've deployed an app, follow the steps below to enable the snapshot debugger:

  1. Navigate to the Azure control panel for your App Service.

  2. Go to the Settings > Application Insights page.

    Enable App Insights on App Services portal

  3. Either follow the instructions on the page to create a new resource or select an existing App Insights resource to monitor your app. Also make sure both switches for Snapshot Debugger are On.

    Add App Insights site extension

  4. Snapshot Debugger is now enabled using an App Services App Setting.

    App Setting for Snapshot Debugger

Enable Snapshot Debugger for china cloud

Connection String Property China Cloud
SnapshotEndpoint https://snapshot.monitor.azure.cn

For more information about other connection overrides, see Application Insights documentation.

Enable Azure Active Directory authentication for snapshot ingestion

Application Insights Snapshot Debugger supports Azure AD authentication for snapshot ingestion. This means, for all snapshots of your application to be ingested, your application must be authenticated and provide the required application settings to the Snapshot Debugger agent.

As of today, Snapshot Debugger only supports Azure AD authentication when you reference and configure Azure AD using the Application Insights SDK in your application.

Below you can find all the steps required to enable Azure AD for profiles ingestion:

  1. Create and add the managed identity you want to use to authenticate against your Application Insights resource to your App Service.

    a. For System-Assigned Managed identity, see the following documentation

    b. For User-Assigned Managed identity, see the following documentation

  2. Configure and enable Azure AD in your Application Insights resource.

  3. Add the following application setting, used to let Snapshot Debugger agent know which managed identity to use:

For System-Assigned Identity:

App Setting Value
APPLICATIONINSIGHTS_AUTHENTICATION_STRING Authorization=AAD

For User-Assigned Identity:

App Setting Value
APPLICATIONINSIGHTS_AUTHENTICATION_STRING Authorization=AAD;ClientId={Client id of the User-Assigned Identity}

Disable Snapshot Debugger

Follow the same steps as for Enable Snapshot Debugger, but switch both switches for Snapshot Debugger to Off.

We recommend you have Snapshot Debugger enabled on all your apps to ease diagnostics of application exceptions.

Azure Resource Manager template

For an Azure App Service, you can set app settings within the Azure Resource Manager template to enable Snapshot Debugger and Profiler, see the below template snippet:

{
  "apiVersion": "2015-08-01",
  "name": "[parameters('webSiteName')]",
  "type": "Microsoft.Web/sites",
  "location": "[resourceGroup().location]",
  "dependsOn": [
    "[variables('hostingPlanName')]"
  ],
  "tags": { 
    "[concat('hidden-related:', resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName')))]": "empty",
    "displayName": "Website"
  },
  "properties": {
    "name": "[parameters('webSiteName')]",
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]"
  },
  "resources": [
    {
      "apiVersion": "2015-08-01",
      "name": "appsettings",
      "type": "config",
      "dependsOn": [
        "[parameters('webSiteName')]",
        "[concat('AppInsights', parameters('webSiteName'))]"
      ],
      "properties": {
        "APPINSIGHTS_INSTRUMENTATIONKEY": "[reference(resourceId('Microsoft.Insights/components', concat('AppInsights', parameters('webSiteName'))), '2014-04-01').InstrumentationKey]",
        "APPINSIGHTS_PROFILERFEATURE_VERSION": "1.0.0",
        "APPINSIGHTS_SNAPSHOTFEATURE_VERSION": "1.0.0",
        "DiagnosticServices_EXTENSION_VERSION": "~3",
        "ApplicationInsightsAgent_EXTENSION_VERSION": "~2"
      }
    }
  ]
},

Not Supported Scenarios

Below you can find scenarios where Snapshot Collector is not supported:

Scenario Side Effects Recommendation
When using the Snapshot Collector SDK in your application directly (.csproj) and you have enabled the advance option "Interop". The local Application Insights SDK (including Snapshot Collector telemetry) will be lost, therefore, no Snapshots will be available.

Your application could crash at startup with System.ArgumentException: telemetryProcessorTypedoes not implement ITelemetryProcessor.

For more information about the Application Insights feature "Interop", see the documentation.
If you are using the advance option "Interop", use the codeless Snapshot Collector injection (enabled thru the Azure Portal UX)

Next steps

  • Generate traffic to your application that can trigger an exception. Then, wait 10 to 15 minutes for snapshots to be sent to the Application Insights instance.
  • See snapshots in the Azure portal.
  • For help with troubleshooting Snapshot Debugger issues, see Snapshot Debugger troubleshooting.