Un servizio di database relazionale di Azure.
Azure SQL Database authentication fails when accessed from Azure Function (Login failed for user '<token-identified principal>')
Roberto Patuelli
0
Punti di reputazione
Azure SQL Database authentication fails when accessed from Azure Function (Flex Consumption) using Azure AD Managed Identity (User Assigned).
The issue started suddenly after a period of correct operation, without any application or configuration changes.
Environment:
- Azure Function App (Flex Consumption)
- .NET 8 isolated worker
- Microsoft.Data.SqlClient 7.0.0
- Authentication: Active Directory Managed Identity (User Assigned)
Identity details:
- Token AppId matches SQL EXTERNAL_USER SID
- SQL user exists and is mapped via FROM EXTERNAL PROVIDER
- Entra admin is correctly configured on the SQL server
Observed behavior:
- Access token is successfully acquired from DefaultAzureCredential
- Token is valid and contains correct tenant, appid and oid
- Connection attempt fails with:
Login failed for user '<token-identified principal>' (Error 18456, State 1)
The same issue occurs both when:
- Using SqlConnection.AccessToken manually
- Using Authentication=Active Directory Managed Identity
Expected behavior:
- Azure SQL should authenticate the Managed Identity successfully
Impact:
- Production Azure Function cannot access Azure SQL Database
Database SQL di Microsoft Azure
Database SQL di Microsoft Azure
Accedi per rispondere