question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Azure.Messaging.EventGrid SDK does not parse KeyVault system event data types correctly due to case mismatch

See original GitHub issue

Describe the bug I’ve been trying to work with some KeyVault events, and have found that using the new Azure.Messaging.EventGrid SDK to read the events produces blank objects. The object instance is the correct type, but all properties are null. As best as I can tell, this is because the delivered events use a different casing than the SDK expects. For instance, here is a (slightly cleaned up) event instance:

{
    "id": "39869b5c-6d56-404b-aab8-50ec200f93f8",
    "topic": "/subscriptions/***/resourceGroups/sample-rg/providers/Microsoft.KeyVault/vaults/sample-vault",
    "subject": "TestSecret",
    "eventType": "Microsoft.KeyVault.SecretNewVersionCreated",
    "data": {
        "Id": "https://sample-vault.vault.azure.net/secrets/TestSecret/a9f4eab27ec64771ac1fb07d38fdbae2",
        "VaultName": "sample-vault",
        "ObjectType": "Secret",
        "ObjectName": "TestSecret",
        "Version": "a9f4eab27ec64771ac1fb07d38fdbae2",
        "NBF": 1627491993,
        "EXP": 1690563970
    },
    "dataVersion": "1",
    "metadataVersion": "1",
    "eventTime": "2021-07-28T17:08:38.2145376Z"
}

The casing on the data properties is title-cased (documented as such here), but the SDK expects camel-casing (as code-generated here). The Microsoft.Azure.EventGrid SDK appears to have used this incorrect casing too (here), but it still produced working event data instances since NSJ fuzzy-matched on the property keys. I can get the object to parse correctly if I modify the payload to have the expected casing, but that’s not something I’d want to deploy.

There may be other event data structures beyond KeyVault types that have this inconsistency as well, but I haven’t looked too closely. For now, I’m moving back to the previous-generation SDK so that I can be unblocked here, but this seems like a pretty glaring bug in the new SDK. Hopefully I can update back to it at some point. 😄

Expected behavior Azure.Messaging.EventGrid parses KeyVault SecretNewVersion (and other) event data structures correctly.

Actual behavior (include Exception or Stack Trace) An instance of the correct type is provided, but it has all null values.

To Reproduce Steps to reproduce the behavior (include a code snippet, screenshot, or any additional information that might help us reproduce the issue)

  1. Create a Key Vault.
  2. Register an event subscription for New Secret Version events.
  3. Parse the provided payload with Azure.Messaging.EventGrid.

Environment:

  • Name and version of the Library package used: Azure.Messaging.EventGrid 4.5.0
  • Hosting platform or OS and .NET runtime version (dotnet --info output for .NET Core projects): .NET Core 3.1 and 5.0
  • IDE and version : Visual Studio 16.10.4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
AtOMiCNebulacommented, Aug 13, 2021

Thanks, #23208 / v4.6.0 works!

1reaction
JoshLove-msftcommented, Aug 13, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] Can't send complex object as data in EventGridEvent
Describe the bug Trying the new Event Grid SDK, sending data as a string in the event, serialized successfully, But trying to send...
Read more >
[BUG] DeserializeEventGridEvents is not working when ...
Describe the bug I have not tried all consumer, but when trying it with the Azure Service Bus Queue, the data does not...
Read more >
function app can't send message to event grid
SendEventAsync(egEvent) gives me exception error: The given key '1' was not present in the dictionary. I get the key using the azure portal...
Read more >
Azure Event Grid client library for .NET
Event delivery · Parse events from JSON into individual events. Based on the event schema (Event Grid or CloudEvents), you can now access...
Read more >
Azure Key Vault as Event Grid source
Describes the properties and schema provided for Azure Key Vault events with Azure Event Grid.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found