Call External API when a document is uploaded to Team general channel?

john john Pter 1,570 Reputation points
2026-09-05T23:12:04.0633333+00:00

i have an azure function which provision a SharePoint site and a teams, now i want to add a functionality when a document is uploaded to the general channel to send the file to external API and receive a document, the endpoint is an AI endpoint that summarize the document, so how i can implement this functionality?

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.


2 answers

Sort by: Most helpful
  1. Andrew Taylor - COREZENN 1,390 Reputation points Volunteer Moderator
    2026-09-06T23:24:48.17+00:00

    Hi @john john Pter

    Thank you for reaching out to Microsoft Q&A. I would implement this as a Microsoft Graph change-notification workflow for the SharePoint folder behind the Team's General channel. The notification endpoint should only validate and queue work; a separate Function should download the file, call the AI service, and upload the generated document.

    Implementation Approach

    When your provisioning Function creates the Team, retain the Team ID and obtain the General channel's file location:

    GET https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{general-channel-id}/filesFolder
    

    This returns the channel's SharePoint-backed driveItem including the drive and folder identifiers needed for subsequent file operations. Get filesFolder

    Then create a Microsoft Graph subscription for file changes in that Drive/DriveItem. Point its notificationUrl at a public HTTPS HTTP-triggered Azure Function. Graph validates that endpoint by sending validationToken as a query parameter; the Function must return the URL-decoded token as text/plain with 200 OK within 10 seconds or the subscription is not created. Receive change notifications through webhooks

    For each ordinary notification, I would use this flow:

    1. Check that the received clientState matches the random value supplied when the subscription was created. Receive change notifications through webhooks
    2. Put the drive item ID and notification metadata on Azure Storage Queue or Service Bus, then return 202 Accepted promptly. Graph recommends queueing when processing cannot finish within three seconds; it can retry notifications, so the handler should be idempotent. Receive change notifications through webhooks
    3. In a queue-triggered Function, obtain the current item metadata and download its content with GET /drives/{drive-id}/items/{item-id}/content. Downloading a file with application permissions requires at least Files.Read.All. Download driveItem content
    4. Check the file type and size against the AI endpoint's supported inputs, send the content to that endpoint, and generate a distinct result name such as original-name-summary.docx so that the result upload does not retrigger processing of itself.
    5. Upload the result to the same folder, or another designated folder, through Graph. A simple content upload supports files up to 250 MB and requires Files.ReadWrite.All for application permissions; use an upload session for larger results. Upload or replace the contents of a driveItem

    Persist the Graph subscription ID, monitored resource, expiration time, and clientState. Subscriptions expire and must be renewed. I would also configure lifecycle notifications and a timer-triggered renewal/reconciliation job, because notifications can be delayed, duplicated, or missed. subscription resource type Reduce missing subscriptions and change notifications

    From my experience, keep the AI endpoint credential in Key Vault or Function app settings, never in source code or a SharePoint document. Grant only the Graph permissions needed for the selected read/write design, and restrict which file extensions and folders the worker accepts before content leaves Microsoft 365.

    Please 'Upvote' (Thumbs-up) and 'Accept' as answer if the response was helpful. This will benefit other community members who face the same issue.

    Best regards, Andrew S Taylor

    Was this answer helpful?

    0 comments No comments

  2. SHOUMIK CHAKRAVARTY 575 Reputation points
    2026-09-06T22:05:42.9633333+00:00

    The comment's mentioned is right that you watch SharePoint, not Teams. But there's no SharePoint trigger for Azure Functions. You want Graph change notifications.

    1. Create a Graph subscription on the drive root of the Team's site. Not the General folder- on OneDrive for Business you can only subscribe to the root.
    2. Point it at an HTTP-triggered Function. That Function has to echo back the validation token when the subscription is created, or Graph rejects it.
    3. When a notification arrives, call /drives/{drive-id}/root/delta. The notification only tells you something changed, not what.
    4. Filter the delta results to the General path, download the file, POST it to your AI endpoint.
    5. Add a timer Function to renew the subscription. They expire, and it stops silently when they do.

    If you'd rather not host and validate your own endpoint (step 2), Event Grid can receive Graph events directly.

    Help make this community better for everyone: if this answer resolved your issue, please accept it or leave an upvote. If not, share more details in a comment so we can continue the discussion and find the right solution.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.