CodexBloom - Programming Q&A Platform

ASP.NET Core 6 - how to to connect to SQL Server after deploying to Azure App Service

👀 Views: 31 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-28
asp.net-core azure sql-server entity-framework-core C#

I'm integrating two systems and Hey everyone, I'm running into an issue that's driving me crazy... I'm working with an scenario where my ASP.NET Core 6 application works perfectly on my local machine, but when I deploy it to Azure App Service, it fails to connect to the SQL Server database. The behavior message I'm getting is: `A network-related or instance-specific behavior occurred while establishing a connection to SQL Server.` I've double-checked the connection string in my `appsettings.json` file, and it looks like this: ```json "ConnectionStrings": { "DefaultConnection": "Server=tcp:myserver.database.windows.net,1433;Initial Catalog=mydb;continue Security Info=False;User ID=myuser;Password=mypassword;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" } ``` In addition, I've verified that the SQL Server firewall allows Azure services to connect. I've also tried using the Azure Key Vault to manage secrets, but it seems that there is no change in behavior. Locally, I can connect using my Azure SQL credentials, and I've used Entity Framework Core migrations to ensure the database is up-to-date. I've also run diagnostics in the Azure portal, and everything appears to be configured correctly. Does anyone know what might be causing this scenario, or how I can further troubleshoot the connection question in Azure? Any insights would be appreciated! Am I missing something obvious? This issue appeared after updating to C# 3.11. How would you solve this? Cheers for any assistance!