I am trying to develop an Azure Function to act upon a blob created by the Capture feature of an Event Hub. However, whereas capture blobs are correctly stored on the container, it seems that no Microsoft.EventHub.CaptureFileCreated
event is published to the Function subscription. The event subscription to the function endpoint has been created without errors, and the output from the Azure CLI is
{
"additionalProperties": {},
"deadLetterDestination": null,
"destination": {
"additionalProperties": {},
"endpointBaseUrl": "https://xxxxx-xxxxx-xxxxx.azurewebsites.net/api/EventGridWebhook",
"endpointType": "WebHook",
"endpointUrl": null
},
"eventDeliverySchema": "InputEventSchema",
"filter": {
"additionalProperties": {},
"includedEventTypes": [
"Microsoft.EventHub.CaptureFileCreated"
],
"isSubjectCaseSensitive": null,
"subjectBeginsWith": "",
"subjectEndsWith": ""
},
"id": "/subscriptions/yyyyy-yyyyy-yyyyyy/resourceGroups/test-event-grid-grp/providers/Microsoft.EventHub/namespaces/capture-hub-namespace/providers/Microsoft.EventGrid/eventSubscriptions/captureFunctionV1Sub",
"labels": null,
"name": "captureFunctionV1Sub",
"provisioningState": "Succeeded",
"resourceGroup": "test-event-grid-grp",
"retryPolicy": {
"additionalProperties": {},
"eventTimeToLiveInMinutes": 1440,
"maxDeliveryAttempts": 30
},
"topic": "/subscriptions/yyyyy-yyyyy-yyyyyy/resourceGroups/test-event-grid-grp/providers/microsoft.eventhub/namespaces/capture-hub-namespace",
"type": "Microsoft.EventGrid/eventSubscriptions"
}
The body of the function is a standard Http trigger with the additional validation part needed for the Event Grid endpoint subscription
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
{
string jsonContent = await req.Content.ReadAsStringAsync();
log.Info($"Webhook was triggered! Input: {jsonContent}");
dynamic events = JsonConvert.DeserializeObject(jsonContent);
if (req.Headers.GetValues("Aeg-Event-Type").FirstOrDefault() == "SubscriptionValidation")
{
var code = events[0].Data["validationCode"];
return req.CreateResponse(HttpStatusCode.OK,
new { validationResponse = code });
}
return req.CreateResponse(HttpStatusCode.OK);
}
As an experiment, if I add the same function's endpoint for another type of event (f.i. a blob creation event), I can see the function invocations in the logs. Besides, in the Metrics blade of the event subscription, it seems like no event is ever published to the subscribers
Moreover, adding a subscription from the capture event to a Logic App or to a Storage Queue resulted in zero events being published, as with the webhook trigger. It is also worth noting that this doesn't work using both runtime environments for Azure functions (v1 and v2), and even when using the specific EventGridTrigger
attribute instead of a generic Http trigger; however, other event types correctly publish the events and trigger the function.
For reference on possible reproduction steps, I took inspiration from this Microsoft tutorial, skipping the SQL Server/Data Warehouse part. While searching for other people having similar issue, I found this question which seems related to my case, but there is no clear answer or clue about what could be the problem. Something must be missing, but I have no idea what to try next.