Wrong error message when missing proper access while using `DefaultAzureCredential`
See original GitHub issueDescribe the bug
I have used management api to connect to signalr service with DefaultAzureCredential
. I have a service principal set up in the env variables. I have forgotten to give “SignalR Service Owner” role access to that SP and the error that I got when trying to connect was this:
Azure SignalR Service is not connected yet, please try again later.
This is a quite misleading error as the real error should be Forbidden/Unauthorized somewhere deep.
To Reproduce
Register service manager like this:
var serviceManager = new ServiceManagerBuilder()
.WithOptions(o =>
{
o.ServiceTransportType = ServiceTransportType.Persistent;
o.ServiceEndpoints = new[]
{
new ServiceEndpoint(new Uri("real url"), new DefaultAzureCredential())
};
})
.BuildServiceManager();
Then create a hub context and try to negotiate:
var response = await serviceHubContext.NegotiateAsync(new NegotiationOptions
{
UserId = "some id"
});
Exceptions (if any)
Microsoft.Azure.SignalR.Common.AzureSignalRNotConnectedException: Azure SignalR Service is not connected yet, please try again later. at Microsoft.Azure.SignalR.DefaultEndpointRouter.GetNegotiateEndpoints(IEnumerable
1 endpoints) at Microsoft.Azure.SignalR.DefaultEndpointRouter.GetNegotiateEndpoint(HttpContext context, IEnumerable
1 endpoints) at Microsoft.Azure.SignalR.Management.NegotiateProcessor.NegotiateAsync(String hubName, NegotiationOptions negotiationOptions, CancellationToken cancellationToken) at SignalRManager.Api.Web.Controllers.NegotiateController.Negotiate(String hub) in C:\Source.…\NegotiateController.cs:line 32 at lambda_method73(Closure , Object ) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Authentication.Middleware.ExceptionHandlerMiddleware.InvokeAsync(HttpContext context, IHostingEnvironment environment) at Authentication.Middleware.ExceptionHandlerMiddleware.InvokeAsync(HttpContext context, IHostingEnvironment environment) at SignalRManager.Api.Web.Middleware.ExceptionHandlerMiddleware.InvokeAsync(HttpContext context, IWebHostEnvironment environment) in C:\Source.…\Web\Middleware\ExceptionHandlerMiddleware.cs:line 39 at SignalRManager.Api.Web.Middleware.ExceptionHandlerMiddleware.InvokeAsync(HttpContext context, IWebHostEnvironment environment) in C:\Source.…\Web\Middleware\ExceptionHandlerMiddleware.cs:line 50 at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Further technical details
- Your Azure SignalR SDK version: 1.10.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
AzureSignalRNotConnectedException
with error message "Azure SignalR Service is not connected yet, please try again later.“ is thrown because every negotiation will check whether SignalR Service is connected in version 1.10.0. This behaviour is initially designed for multiple SignalR Service instances scenario where we can choose the healthy SignalR instance for users. But it was also introduced into single SignalR instance scenario in version 1.10.0 by mistake. We will remove this confusing behaviour for single SignalR instance in the next release.#1435
1.11.0 released