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.

Event Grid SDK works with .NET Core on Windows, but not Mac

See original GitHub issue

Describe the bug I tried running the sample code in the documentation (which is great, BTW, thanks!) originally under .NET Core 3.0pre4. It didn’t work so I recreated the scenario on .NET Core 2.2. The error is the same in both cases on a Mac.

Whenever this line of code, from the documentation, is executed on a Mac:

EventGridClient client = new EventGridClient(topicCredentials);

This exception is thrown:

Exception or Stack Trace

`System.FormatException: The format of value 'Darwin18.2.0DarwinKernelVersion18.2.0ThuDec20204653PST2018rootxnu-4903.241.11/RELEASE_X86_64' is invalid.
   at System.Net.Http.Headers.HeaderUtilities.CheckValidToken(String value, String parameterName)
   at System.Net.Http.Headers.ProductHeaderValue..ctor(String name, String version)
   at Microsoft.Rest.ServiceClient`1.UpdateDefaultUserAgentList(String headerName, String headerValue)
   at Microsoft.Rest.ServiceClient`1.get_DefaultUserAgentInfoList()
   at Microsoft.Rest.ServiceClient`1.InitializeHttpClient(HttpClient httpClient, HttpClientHandler httpClientHandler, DelegatingHandler[] handlers)
   at Microsoft.Azure.EventGrid.EventGridClient..ctor(ServiceClientCredentials credentials, DelegatingHandler[] handlers)
   at APIs.Orders.Controllers.OrdersController.Post(Order order) in /Users/bradygaster/source/OrderProcess-2_2/APIs.Orders/Controllers/OrdersController.cs:line 23
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.<>c__DisplayClass33_0.<WrapVoidMethod>b__0(Object target, Object[] parameters)
   at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.VoidResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

To Reproduce

  1. Complete the CLI Quick Start to get resources created and to validate the event grid is working.

  2. Clone code that demonstrates this issue from this repository.

  3. Open the code using Visual Studio Code or Visual Studio for Mac on a Mac.

  4. Configure OrdersController.cs with the proper URL and key.

    string topicEndpoint = "url";
    string topicKey = "key";
    
  5. Debug the project

  6. Use postman or curl to send the JSON payload below to https://localhost:5001/api/orders.

{
	"orders" : [
		{
			"productId" : "27980596-6f6c-437f-b9af-81f2bb762d32",
			"quantity" : 2,
			"price" : 5.99
		},
		{
			"productId" : "fc2a9925-c536-416c-b1ce-205a1037ea43",
			"quantity" : 4,
			"price" : 3.99
		}
	]
}
  1. Note the error.
  2. Run the same code in Visual Studio on Windows.
  3. Note there is no error, and the message is sent to Event Grid.

Code Snippet This code from the doc seems to be when the error occurs.

EventGridClient client = new EventGridClient(topicCredentials);

Expected behavior The SDK should work the same way on Windows, Mac, and Linux. There should be no difference in the platform’s behavior when using the SDK.

Screenshots If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: MacBook
  • IDE : Visual Studio Code, Visual Studio for Mac, dotnet run, versions 2.2 and 3.0-preview4 of .NET Core.
  • Event Grid SDK version 3.0

Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
AlexGhiondeacommented, Apr 18, 2019

@bradygaster we released an updated version of the EventGrid package: https://www.nuget.org/packages/Microsoft.Azure.EventGrid/3.1.0

Can you give that a try and see if the issue is still reproducing?

1reaction
Petermarcucommented, Mar 17, 2019

@bradygaster , sounds like we should be shipping an updated EvenGrid package with a reference to the newer ClientRuntime then. Sound right? @AlexGhiondea can you help coordinate that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing the new Azure Event Grid Client Libraries
Version 4 of the Azure Event Grid packages have now been released (.NET, Java, Python and JavaScript/TypeScript), following the new Azure SDK ......
Read more >
Introducing the new Azure Event Grid Client Libraries with ...
We are excited to announce the release of the new Azure Event Grid client library's first beta for .NET, Java, JavaScript, and Python!...
Read more >
Azure EventGrid SDK for .NET
Build event-driven applications that listen and react to events from Azure services and custom sources using simple HTTP-based event handling ...
Read more >
Overview - Azure Event Grid
Build event-driven serverless solutions​​ Use Event Grid to build serverless solutions with Azure Functions Apps, Logic Apps, and API Management.
Read more >
Azure Event Grid, Event Hubs, and Service Bus Library ...
Azure Event Hubs SDK Highlights. Simpler clients, consistent experience. Clients are usually the entry point into a library. This means before ...
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