wasAsked.

What is the difference between event grid trigger and Httptrigger in azure function? When would you use each?

Wipro · Role not specified · technical

Published

Year not specified · Azure

Community answers

Posted by wasAsked editorial collection

Both start an Azure Function, but they represent different integration styles. HTTP trigger - Runs when an HTTP request arrives at the function's URL. - Synchronous request/response: the caller waits and receives the function's response (status code and body). - Caller: browsers, mobile apps, other services, webhooks from third parties. - Security: function keys, Entra ID authentication (Easy Auth or JWT validation), or API Management in front. - Limit: must respond within about 230 seconds; longer work should be queued and handled asynchronously. - Use when: you are building an API endpoint or need an immediate answer — "get order status", "create order", a webhook receiver. Event Grid trigger - Runs when Azure Event Grid delivers an event, such as BlobCreated in Storage, a resource change in a subscription, a Key Vault secret near expiry, or a custom event published by your application to an Event Grid topic. - Push-based, reactive and asynchronous: the publisher does not wait for the function's result. - Event Grid handles subscription validation, filtering (by event type or subject prefix), retries with exponential backoff for up to 24 hours by default, and dead-lettering to a storage account. - Events use the Event Grid schema or the CloudEvents schema. - Use when: reacting to something that happened — process an uploaded image, sync data after a change, start a workflow when a resource is created. Choosing between them - Need a response for the caller? HTTP trigger. - Reacting to state changes in Azure services or your own events, with fan-out to many subscribers? Event Grid trigger. - High-volume telemetry streams? Event Hubs trigger instead. - Reliable business commands with ordering and dead-letter queues? Service Bus trigger instead. Note: Event Grid can also deliver to a webhook (an HTTP endpoint), but the Event Grid trigger binding handles validation and deserialisation for you, and enables identity-based delivery and filtering more cleanly. Example from a project: "Users uploaded documents directly to Blob Storage with a SAS URL; an Event Grid BlobCreated event triggered a function that scanned and indexed the file, while the HTTP-triggered function only issued the upload URL."

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics