Skip to content

Latest commit

 

History

History
96 lines (70 loc) · 3.59 KB

File metadata and controls

96 lines (70 loc) · 3.59 KB
title sdk description
Azure Functions
sentry.dotnet.azure.functions.worker
Learn about Sentry's .NET integration with Azure Functions.

Sentry provides an integration with Azure Functions through the Sentry.Azure.Functions.Worker NuGet package. All triggers are supported.

Features

In addition to capturing errors, you can monitor interactions between multiple services or applications by enabling tracing.

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.

Install

<OnboardingOptionButtons options={['error-monitoring', 'performance']}/>

Add the Sentry dependency to your Azure Functions application:

dotnet add package Sentry.Azure.Functions.Worker -v {{@inject packages.version('sentry.dotnet.azure.functions.worker') }}
Install-Package Sentry.Azure.Functions.Worker -Version {{@inject packages.version('sentry.dotnet.azure.functions.worker') }}

This package extends Sentry.Extensions.Logging. This means that besides the Azure Functions related features, through this package you'll also get access to the ILogger<T> integration and also the features available in the main Sentry SDK.

Configure

Sentry integration with Azure Functions is done by calling .UseSentry() and specifying the options, for example:

using Sentry.Azure.Functions.Worker;

var builder = FunctionsApplication.CreateBuilder(args);

builder.UseSentry(options =>
{
    options.Dsn = "___PUBLIC_DSN___";
    // When configuring for the first time, to see what the SDK is doing:
    options.Debug = true;
    // Adds request URL and headers, IP and name for users, etc.
    options.SendDefaultPii = true;
    // ___PRODUCT_OPTION_START___ performance
    // Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring.
    // We recommend adjusting this value in production.
    options.TracesSampleRate = 1.0;
    // ___PRODUCT_OPTION_END___ performance
});

builder.Build().Run();

If using the ASP.NET Core integration add UseSentry to the ConfigureFunctionsWebApplication call instead.

using Sentry.Azure.Functions.Worker;

var host = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults((host, builder) =>
    {
        builder.UseSentry(host, options =>
        {
            options.Dsn = "___PUBLIC_DSN___";
            // When configuring for the first time, to see what the SDK is doing:
            options.Debug = true;
            // Adds request URL and headers, IP and name for users, etc.
            options.SendDefaultPii = true;
            // ___PRODUCT_OPTION_START___ performance
            // Set traces_sample_rate to 1.0 to capture 100% of transactions for performance monitoring.
            // We recommend adjusting this value in production.
            options.TracesSampleRate = 1.0;
            // ___PRODUCT_OPTION_END___ performance
        });
    })
    .Build();
await host.RunAsync();

Verify

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.

Samples