Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Can't send complex object as data in EventGridEvent #15137

Closed
Sarah-Aly opened this issue Sep 14, 2020 · 4 comments
Closed

[BUG] Can't send complex object as data in EventGridEvent #15137

Sarah-Aly opened this issue Sep 14, 2020 · 4 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Grid needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@Sarah-Aly
Copy link

Sarah-Aly commented Sep 14, 2020

Describe the bug
Trying the new Event Grid SDK, sending data as a string in the event, serialized successfully, But trying to send a complex object as the data in the event, I get empty data in the consumer

Expected behavior
Be able to send complex objects as data in EventGridEvent

Actual behavior (include Exception or Stack Trace)
complex object data is not serialized correctly & we get empty data in the consumer (event grid trigger azure function)
image

To Reproduce

    class data
    {
        string name;
        string value;
        public data(string name, string value)
        {
            this.name = name;
            this.value = value;
        }
    }

    class Program
    {
        static Uri endpoint = new Uri("<EG-TOPIC-ENDPOINT>");
        static AzureKeyCredential azureKey = new AzureKeyCredential("<AEG-SAS-KEY>");
        static void Main(string[] args)
        {
            EventGridPublisherClient eventGridPublisherClient = new EventGridPublisherClient(endpoint, azureKey);
            var events = new List<EventGridEvent>();
            // this sends empty data
            events.Add(new EventGridEvent(new data("test3", "event grid schema"), "subject 3", "eventType 3", "1.0"));
            // this sends correct data
            events.Add(new EventGridEvent("ping pong", "subject 4", "eventType 4", "1.0"));
            eventGridPublisherClient.SendEvents(events);
        }
    }

Environment:

  • Name and version of the Library package used: Azure.Messaging.EventGrid -Version 4.0.0-beta.1
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 14, 2020
@jsquire jsquire added Client This issue points to a problem in the data-plane of the library. Event Grid needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Sep 14, 2020
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 14, 2020
@jsquire
Copy link
Member

jsquire commented Sep 14, 2020

Hi @Sarah-Aly. Thank you for your feedback; tagging and routing to the team member best able to assist.

@JoshLove-msft
Copy link
Member

JoshLove-msft commented Sep 14, 2020

@Sarah-Aly, it looks like the issue is that your type is using fields rather than properties.
Also the properties would need to be public for serialization to work with the default serializer - System.Text.Json.
See https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-how-to#serialization-behavior for current behavior.

It looks like in .NET 5.0, field support is being added to System.Text.Json dotnet/runtime#41313

@JoshLove-msft
Copy link
Member

We should update the documentation to make it clear what the default constraints w.r.t. serialization are.

@Sarah-Aly
Copy link
Author

This works. Thanks @JoshLove-msft.
Closing the issue.

openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-net that referenced this issue Jul 20, 2021
[WebPubSub] New api for generating token (Azure#15137)

* init

* update
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Grid needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants