Bilješka
Pristup ovoj stranici zahtijeva provjeru vjerodostojnosti. Možete pokušati da se prijavite ili promijenite direktorije.
Pristup ovoj stranici zahtijeva provjeru vjerodostojnosti. Možete pokušati promijeniti direktorije.
Snapshot Debugger currently works for ASP.NET and ASP.NET Core apps that run on Azure Functions on Windows service plans.
Run your application on the Basic or higher service tiers when you use Snapshot Debugger. For most applications:
- The Free and Shared service tiers don't have enough memory or disk space to save snapshots.
- The Consumption tier isn't currently available for Snapshot Debugger.
Snapshot Debugger is preinstalled as part of the Azure Functions runtime. You don't need to add extra NuGet packages or application settings.
Prerequisites
Before you enable Snapshot Debugger, enable Application Insights monitoring in your function app. Snapshot Debugger relies on Application Insights to store and display captured snapshots.
Enable Snapshot Debugger
To enable Snapshot Debugger in your function app, add the snapshotConfiguration property to your host.json file and redeploy your function. For example:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"snapshotConfiguration": {
"isEnabled": true
}
}
}
}
Generate traffic to your application that triggers an exception. Then wait 10 to 15 minutes for the snapshots to reach the Application Insights instance.
To verify that Snapshot Debugger is enabled, check your .NET function app files. For example, in the following simple .NET function app, the .csproj, {Your}Function.cs, and host.json of your .NET application show Snapshot Debugger as enabled:
Project.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.31" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
{Your}Function.cs
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
namespace SnapshotCollectorAzureFunction
{
public static class ExceptionFunction
{
[FunctionName("ExceptionFunction")]
public static Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
throw new NotImplementedException("Dummy");
}
}
}
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
},
"snapshotConfiguration": {
"isEnabled": true
}
}
}
}
Enable Snapshot Debugger for other clouds
Currently, the only regions that require endpoint modifications are Azure Government and Microsoft Azure operated by 21Vianet.
The following example shows the host.json updated with the Azure Government agent endpoint:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
},
"snapshotConfiguration": {
"isEnabled": true,
"agentEndpoint": "https://snapshot.monitor.azure.us"
}
}
}
}
The following table lists the supported overrides of the Snapshot Debugger agent endpoint:
| Property | Azure Government | Azure operated by 21Vianet |
|---|---|---|
agentEndpoint |
https://snapshot.monitor.azure.us |
https://snapshot.monitor.azure.cn |
Disable Snapshot Debugger
To disable Snapshot Debugger in your function app, update your host.json file by setting the snapshotConfiguration.isEnabled property to false.
{
"version": "2.0",
"logging": {
"applicationInsights": {
"snapshotConfiguration": {
"isEnabled": false
}
}
}
}
Related content
- View snapshots in the Azure portal.
- Customize Snapshot Debugger configuration based on your use case on your function app. For more information, see Snapshot configuration in host.json.
- Troubleshoot Snapshot Debugger issues.