A @bugsnag/js plugin for capturing errors in Azure Functions.
yarn add bugsnag-js-plugin-azure-functions
# or
npm install --save bugsnag-js-plugin-azure-functions
To start Bugsnag with the Azure Functions integration, pass the plugin to Bugsnag.start:
const Bugsnag = require('@bugsnag/js')
const BugsnagPluginAzureFunctions = require('bugsnag-js-plugin-azure-functions')
Bugsnag.start({
plugins: [BugsnagPluginAzureFunctions],
})
Start handling errors in your Azure function by wrapping your handler with Bugsnag’s handler:
const bugsnagHandler = Bugsnag.getPlugin('azureFunctions').createHandler()
const handler = async (context, req) => {
return {
status: 200,
body: JSON.stringify({ message: 'Hello, World!' })
}
}
module.exports = bugsnagHandler(handler)
Bugsnag will automatically capture the Azure function's context
in the "Azure Functions context" tab on every error.
The Bugsnag Azure Functions plugin can be configured by passing options to createHandler.
flushTimeoutMs
Bugsnag will wait for events and sessions to be delivered before allowing the Azure function to exit. This option can be used to control the maximum amount of time to wait before timing out.
By default, Bugsnag will timeout after 2000 milliseconds.
const bugsnagHandler = Bugsnag.getPlugin('azureFunctions').createHandler({
flushTimeoutMs: 5000
})
If a timeout does occur, Bugsnag will log a warning and events & sessions may not be delivered.
This package is free software released under the MIT License.