Event Grid SDK works with .NET Core on Windows, but not Mac
See original GitHub issueDescribe 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
-
Complete the CLI Quick Start to get resources created and to validate the event grid is working.
-
Clone code that demonstrates this issue from this repository.
-
Open the code using Visual Studio Code or Visual Studio for Mac on a Mac.
-
Configure
OrdersController.cs
with the proper URL and key.string topicEndpoint = "url"; string topicKey = "key";
-
Debug the project
-
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
}
]
}
- Note the error.
- Run the same code in Visual Studio on Windows.
- 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:
- Created 5 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
@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?
@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?