Demonstrate how to set up end-to-end tracing using application insights.
Currently there is no support for end-to-end tracing between the Azure Event Grid and an Event Grid triggered Azure Function when using the Event Grid Event schema. Right now Microsoft is working to address this by supporting end-to-end tracing using the CloudEvents schema and an Event Grid triggered Azure Function.
In the end, for end to end tracing to work existing integrations that use the Event Grid Event schema need to be modified to use the CloudEvents schema. Until that moment the work around as described in the repository kan be used. It will track the complete flow in Application Insights resulting in an end-to-end trace like this:
The solution contains three functions:
EventInitiator: [GET,POST] http://localhost:7071/api/EventInitiator
EventSender: [GET,POST] http://localhost:7071/api/EventSender
EventConsumer: eventGridTrigger
The EventInitiator triggers the EventSender to send an Event that will be consumer by the EventConsumer function. The whole flow is visible as one operation in Application Insights.
- Clone the repository.
- Create an Event Grid Topic and store the topic name and topic key in the
local.settings.json
file with keysEG-Topic
andEG-Key
. - Create an Application Insights Resource and add a key
APPINSIGHTS_INSTRUMENTATIONKEY
to thelocal.settings.json
file. - Create a tunnel using ngrok to expose the function to the outside world. For example:
ngrok http 7071
. - Run the application.
- Create an Event Grid Subscription using the Event Grid Event schema to the topic defined in step 2. Use a webhook as a target and the ngrok url as target url:
https://30c2406a223d.ngrok.io/runtime/webhooks/EventGrid?functionName=EventConsumer
. - Trigger the process by calling the
EventInitiator
method by issuing a GET request:http://localhost:7071/api/EventInitiator
.
Azure/azure-webjobs-sdk#1731
Azure/azure-sdk-for-net#13272
Azure/azure-sdk-for-net#15466