Azure Functions Connector Samples (.NET): Office 365 Outlook webhook

Azure Functions sample using Azure.Connectors.Sdk and the Connector extension. The Connector Namespace delivers events to the function's public HTTPS callback. All handlers use typed payloads and log only the trigger name and item count.

Function Connector operation Description
OnNewEmail OnNewEmailV3 New email
OnFlaggedEmail OnFlaggedEmailV4 Flagged email (preview)
OnNewMentionMeEmail OnNewMentionMeEmailV3 Email mentioning me
OnNewCalendarEvent CalendarGetOnNewItemsV3 New event
OnCalendarUpdatedItems CalendarGetOnUpdatedItemsV3 Modified event
OnUpcomingEvent OnUpcomingEventsV3 Upcoming event
OnSharedMailboxNewEmail SharedMailboxOnNewEmailV2 Shared mailbox email (opt-in)
Not included CalendarGetOnChangedItemsV3 Event added, updated or deleted; preview subscription fails with missing TABLE

Prerequisites

Deploy to Azure

cd office365App/webhook
az login
azd auth login
azd env new office365-webhook
azd env set OFFICE365_MAIL_FOLDER Inbox
azd env set OFFICE365_CALENDAR_ID '<actual connector calendar ID>'
azd up

Use the actual connector calendar ID, not the placeholder Calendar. Complete the OAuth sign-in opened by azd up with the mailbox account to monitor. Use a different azd environment from polling.

Optional configuration

Set environment values before azd up. Six personal triggers are configured by default.

Setting / option Purpose
OFFICE365_SHARED_MAILBOX_ADDRESS=<address> Shared mailbox email; full mailbox access required
OFFICE365_SHARED_MAILBOX_FOLDER_ID=Inbox Folder to monitor in the shared mailbox
CONNECTOR_NAMESPACE_LOCATION Namespace region; defaults to westcentralus
APPLICATION_INSIGHTS_LOCATION=eastus2 Telemetry region override if the host region lacks Application Insights
OFFICE365_ENABLE_TRIGGERS=false Register disabled sources without waiting for consent; set true and run azd up to activate
Bash hook In azure.yaml, set shell: sh and run: ./infra/scripts/postdeploy.sh
pwsh ./infra/scripts/postdeploy.ps1 -ConsentLinkOnly / bash ./infra/scripts/postdeploy.sh --consent-link-only Skip browser opening and authorization wait; normal setup still runs, including callback updates

Empty address disables its listener and skips registration. When disabling an existing shared source, also disable/delete its namespace config; skipped resources are not removed automatically. Match the local shared listener's disabled setting to your selection.

Local development

  1. Prepare local.settings.json.

    Use the file generated during successful azd up; existing files are preserved. Only if it is missing, rerun:

    azd hooks run postdeploy
    
  2. Start Azurite in a separate terminal.

    azurite
    
  3. Build and start the local Functions host with authentication enabled.

    dotnet build
    func start --enableAuth
    

    Core Tools v4 bypasses local key authentication by default. Use --enableAuth before exposing the host through a public tunnel so callback requests must present the system key.

  4. Expose port 7071 over public HTTPS. Get the local connector_extension system key from Azurite's azure-webjobs-secrets, not the Azure Function App's key or a function key. Keep it private and use it in the tunnel callback.

  5. From the webhook folder, sign in and register the tunnel callback using its provisioned azd environment. This replaces deployed callbacks.

    az login
    bash ./infra/scripts/postdeploy.sh \
      --callback-base-url 'https://<tunnel-host>' \
      --connector-extension-key '<local-key>'
    

    PowerShell supports equivalent -CallbackBaseUrl / -ConnectorExtensionKey options.

  6. When finished, restore Azure delivery without callback overrides.

    azd hooks run postdeploy
    

Functions host/deployment storage is required. Enable the local shared listener only when configured. Never commit keys, callback URLs, or local settings.

Worker telemetry uses the ConnectorNamespace identity settings: the Function App's system-assigned managed identity in Azure, or standard developer credentials when identity settings are absent locally.

Verify

Check the connection is Connected and selected triggers are Enabled in Connector Namespaces. Generate mail/calendar events and check worker logs for Received <FunctionName> trigger (<Count> items); build/deployment success alone is not real-event verification. Delivery is at least once and source detection may be delayed.

Run azd down --purge when finished.

More