Azure Functions

Create a .venv in the local machine on VS Code, create a Python function, and install the sentry SDK:


Add DSN value in

import sentry_sdk
from sentry_sdk.integrations.serverless import serverless_function


def my_function(...):
  # ...

Use the generic integration by calling the serverless_function decorator. Decorators wrap a function and modify its behavior. Then, deploy and test the function. Check out Sentry's sample apps for detailed examples.


  • Each call of a decorated function will block and wait for current events to be sent before returning. When there are no events to be sent, no delay is added. However, if there are errors, it will delay the return of your serverless function until the events are sent. This is necessary as serverless environments typically reserve the right to kill the runtime/VM when they consider it is unused.

  • You can add more context as described here.

  • Request data is attached to all events: HTTP method, URL, headers, form data, JSON payloads. Sentry excludes raw bodies and multipart file uploads. Sentry also excludes personally identifiable information (such as user ids, usernames, cookies, authorization headers, IP addresses) unless you set send_default_pii to True.

  • Each request has a separate scope. Changes to the scope within a view, for example setting a tag, will only apply to events sent as part of the request being handled.

The maximum amount of time to block overall is set by the shutdown_timeout client option.

You can disable this aspect by decorating with @serverless_function(flush=False) instead.

You can edit this page on GitHub.
On this page