Azure - Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user ''. at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)

Tiaan Opperman 6 Reputation points
2024-03-01T12:26:23.85+00:00

Hi guys

Dont know where to start, we have a SQL server and we recently added a new database which connects to the same SQL as the Production server but will function as our DEV environment.

When trying to run Swagger API calls we get error below:

Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user ''.   at Microsoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exception e)   at Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)   at Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)   at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)   at Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)   at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)   at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)   at Microsoft.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry, SqlConnectionOverrides overrides)   at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)   at Microsoft.Data.SqlClient.SqlConnection.Open()   at DataAccessApi.Repositories.ClientRepository.GetAll() in D:\a\1\s\DataAccessApi\Repositories\ClientRepository.cs:line 33   at lambda_method2(Closure , Object , Object[] )   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()--- End of stack trace from previous location ---   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()--- End of stack trace from previous location ---   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)   at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)   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)ClientConnectionId:67c74bb9-a4a0-4792-a4b3-db0600b252e1Error Number:18456,State:1,Class:14ClientConnectionId before routing:8f7dce97-86d5-4fe2-9ecb-f4e27f756e31Routing Destination:abac48a4ab02.tr1290.southafricanorth1-a.worker.database.windows.net,11009HEADERS=======Accept: text/plainAccept-Encoding: gzip, deflate, brAccept-Language: enCookie: ARRAffinity=71ef569b0a5a7357d10d594ccee812c9d40fec9981d73638dc39a5a39bc00e89; ARRAffinitySameSite=71ef569b0a5a7357d10d594ccee812c9d40fec9981d73638dc39a5a39bc00e89Host: sitenamehidden-hiddenforsecuritypredictabilityapistaging.azurewebsites.netMax-Forwards: 10Referer: https://URLofapp.azurewebsites.net/swagger/index.htmlUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36sec-ch-ua: "Not A(Brand";v="99", "Google Chrome";v="121", "Chromium";v="121"sec-ch-ua-mobile: ?0sec-ch-ua-platform: "Windows"Sec-Fetch-Site: same-originSec-Fetch-Mode: corsSec-Fetch-Dest: emptyX-ARR-LOG-ID: 4d307431-7235-489e-ab75-5dfeba52372cCLIENT-IP: 105.184.164.123:53709DISGUISED-HOST: sitenamehidden-hiddenforsecuritypredictabilityapistaging.azurewebsites.netX-SITE-DEPLOYMENT-ID: sitenamehidden__b771WAS-DEFAULT-HOSTNAME: sitenamehidden-hiddenforsecuritypredictabilityapistaging.azurewebsites.netX-Forwarded-Proto: httpsX-AppService-Proto: httpsX-ARR-SSL: 2048|256|CN=Microsoft Azure TLS Issuing CA 06, O=Microsoft Corporation, C=US|CN=*.azurewebsites.net, O=Microsoft Corporation, L=Redmond, S=WA, C=USX-Forwarded-TlsVersion: 1.2X-Forwarded-For: 105.184.164.123:53709X-Original-URL: /api/ClientX-WAWS-Unencoded-URL: /api/Client

Is this something that I need to add on the SQL permissions or on the database or the storage account?

Thank you in advance, if any light can be shed how to start to troubleshoot this / fix this.

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,654 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,643 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.