Azure-sdk-for-net: Custom Event arguments are not retrieved

Created on 29 Sep 2020  路  10Comments  路  Source: Azure/azure-sdk-for-net

I am trying to retrieve custom event data from Application Insights using this package: https://www.nuget.org/packages/Microsoft.Azure.ApplicationInsights

The custom event names are being correctly deserialized, but the custom event data (which is passed via a TelemetryClient object in another solution) isn't. The data is available in the Azure portal, so there is either a bug in the API surface being used by this library or (more likely) the deserialization code.

Expected:
EventsCustomEventResult.CustomDimensions and EventsCustomEventResult.CustomMeasurements are not null (ideally the additional properties should contain a list of string names and string pairs, respectively).

Actual:
The object is null for custom events that do contain custom properties.

Repro:
Ensure that custom events with additional properties exist in an ApplicationInsights instance (This is easily done with the TelemetryClient) and then run this code:

var activeDirectoryServiceSettings = new ActiveDirectoryServiceSettings
{
    AuthenticationEndpoint = new Uri("https://login.microsoftonline.com"),
    TokenAudience = new Uri("https://api.applicationinsights.io/"),
    ValidateAuthority = true
};

var serviceCredentials = ApplicationTokenProvider.LoginSilentAsync(
        domain: "< DOMAIN >",
        clientId: "< CLIENT ID >",
        secret: "< SECRET >",
        settings: activeDirectoryServiceSettings)
    .GetAwaiter()
    .GetResult();

_applicationInsightsDataClient = new ApplicationInsightsDataClient(serviceCredentials)
{
    AppId = "< APP ID >"
};

var events = _applicationInsightsDataClient.GetCustomEvents(TimeSpan.FromHours(72));

foreach (var e in events.Value)
{
    // EXPECTED:
    // e.CustomDimensions.AdditionalProperties != null
    // e.CustomMeasurements.AdditionalProperties != null
}

.NET Core SDK (reflecting any global.json):
Version: 3.1.402
Commit: 9b5de826fd

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.402\

Client Monitor - ApplicationInsights Service Attention customer-reported needs-team-attention question

Most helpful comment

All 10 comments

An additional note. I can see a similar bug was fixed in the Query library 12 days ago (https://github.com/Azure/azure-sdk-for-net/issues/13042) - Is this something the Microsoft.Azure.ApplicationInsights package depends on internally? If so, then the fix might just be to rebuild and re-publish this package

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @azmonapplicationinsights.

Thank you for your feedback. Tagging and routing to the team best able to assist.

//cc: @geneh

Yes, please switch to https://www.nuget.org/packages/Microsoft.Azure.ApplicationInsights.Query.
Microsoft.Azure.ApplicationInsights should be deprecated.

Fair enough. As well as doing that, would someone mind updating the documentation over here? The sample code will also be out of date now too :-)

Yes, thanks for reporting this.

@geneh It looks like the same fix which was applied to EventsResultDataCustomDimensions in 58a48f0 needs to be applied to EventsResultDataCustomMeasurements as well.

Was this page helpful?
0 / 5 - 0 ratings