To disable local auth for Azure SQL, I made changes to my code to use system-assigned Managed Identity of the Azure app service for connection instead of the usual username/password in the connection string.
But now, one of the stored procedures is throwing an error
String or binary data would be truncated
I tried two ways to connect to SQL Server through the Azure app service:
- Using the new
SqlClientNuGet package:Microsoft.Data.SqlClient - Using older package (
System.Data.SqlClient) and fetching an access token for authentication.
Initially, I thought the issue might be because of the newer NuGet package, but even after modifying the existing code to stick with System.Data.SqlClient and adding extra steps for the token, the issue persists.
Strangely, the problem seems to be tied to Managed Identity authentication. Current service is using connection string with username/password and System.Data.SqlClient nuget in Production environment and is running seamlessly.
I double-checked the stored procedures, but no luck finding issues with values going over limits into the SQL Server tables.
I am not understanding the connection between using ManagedIdentity and failure of stored procedure with a completely different error.
- Version of the solution: .NET 4.7.2
- Version of SQL Server database - v12.0.2000.8
Has anyone else ran into this? Any ideas on how to tackle it would be appreciated.