One Application Insights instance per tenant

Jonathan Cook 0 Reputation points
2023-09-06T14:08:07.29+00:00

I am looking at the approach to using Application Insights with a mutli-tenant solution described here:

https://learn.microsoft.com/en-us/azure/architecture/guide/multitenant/service/application-insights#one-application-insights-instance-per-tenant

The goal is having a single App Service write to multiple Application Insights instances based on the tenant that is making the request to the App Service. Is there an example or further documentation into how I would achieve what is described in the link?

EDIT: I see that you can set the InstrumentationKey for a telemetry item using ITelemetry.Context.InstrumentationKey. I am getting conflicting information as to whether or not setting it in this way effects only the individual item, or if the change might effect other items using the same context.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
{count} votes

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 21,566 Reputation points Moderator
    2023-10-23T07:06:45.7466667+00:00

    Jonathan Cook, apologies for the delayed response as I had been discussing this scenario with the AppInsights team. Here are the key outcomes:

    1. By default, this is not possible with AppInsights SDK as available currently. There could be work-around which might make it work but those are untested and unsupported at the moment.
    2. Another option could be to use **opentelemetry-dotnet **which provides additional benefits including sampling, post-processing, and more. The following links contain features of OTel which could help achieve this ()

    Customizing OpenTelemetry .NET SDK for Tracing

    Tech Preview: OpenTelemetry Transformation Language statements as routing conditions

    These features of OTel will depend on the ability to recognize the tenant-based telemetry for which additional tweaks might be required (for example inclusion of tenant header, if not readily available). While these are some of the options available, they have not been tested extensively for their efficacy and supportability in the current scenario.

    I have also shared feedback and review request for the referenced document in the question for it to include caveats to the architecture discussed from Azure Monitor perspective.

    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.