How to setup Sentry in .NET Azure functions

Viewed 520
1 Answers
  1. Install package Install-Package Sentry.AspNetCore
  2. Setup handling in azure function

        [FunctionName("Function1")]
        public static async Task RunAsync([TimerTrigger("0 */5 * * * *", RunOnStartup = true)] TimerInfo myTimer, ILogger log)
        {
            using (SentrySdk.Init())
            {
                try
                {
                   //Code
                }
                catch (Exception ex)
                {
                    SentrySdk.CaptureException(ex);
                    throw;  //if you want to pass it into Azure
                }
            }
        }
  1. Configure DSN in local.settings.json
  "Values": {
    "SENTRY_DSN": "https://your-dsn-url.ingest.sentry.io/xxx"
  }
Related