You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过Azure SQL连接Kentico:本地正常但Azure App Service部署后连接失败求助

Troubleshooting Azure App Service Connection String Issue for Kentico MVC

Let's break down potential issues and actionable fixes step by step, since you've already covered region alignment and IP whitelisting:

  • Validate Azure App Service Connection String Configuration
    Don't rely solely on the web.config values from your deployment. Azure App Service prioritizes connection strings defined in its portal settings over those in deployed config files. Head to your App Service > Configuration > Connection Strings, add your SQL Server connection string here, ensure the name matches exactly what Kentico expects (typically CMSConnectionString for core databases), and set the type to SQL Server. This ensures the runtime uses the portal-configured value instead of the deployed file's content.

  • Double-Check Connection String Details
    Let's verify your provided string:

    Data Source=tcp:adiadb.database.windows.net,1433;Initial Catalog=adia;User Id=sqladmin@adiadb;Password=password
    
    • Confirm the User Id format is correct: sqladmin@adiadb uses your server name (adiadb) as the suffix, which is the required format for Azure SQL authentication.
    • Ensure the actual password (not the placeholder password) is accurate—typos here are an extremely common culprit.
    • Verify the Initial Catalog (adia) exists on your Azure SQL server and your sqladmin account has read/write permissions for it.
  • Enable Azure SQL Server's "Allow Azure Services" Firewall Rule
    App Service instances use dynamic IPs that change regularly, so static IP whitelists might not cover all cases. Go to your Azure SQL Server > Firewalls and virtual networks, then check the box for "Allow Azure services and resources to access this server". This grants internal Azure services (like your App Service) permission to connect without needing to track individual IP addresses.

  • Dig into App Service Logs for Specific Errors
    Generic "connection failed" messages don't give enough context. Enable detailed logging for your App Service:

    1. Navigate to App Service > Monitoring > Log stream to watch real-time errors.
    2. Look for Kentico-specific logs or SQL connection exceptions (e.g., login failed, server unreachable, database not found).
    3. You can also check the App_Data\CMSLogs folder via your App Service's Kudu console (https://adia.scm.azurewebsites.net > Debug console > CMD) for Kentico's detailed error logs—these will pinpoint exactly why the connection is failing.
  • Check Kentico's Configuration Transformations
    If you're using Web.config transformation files (like Web.Release.config), make sure it isn't overriding the connection string with a local value during deployment. Open your transform file and confirm there's no unintended connectionStrings node that replaces your production string.

  • Test the Connection String Locally First
    Use SSMS or a simple console app to test connecting to your Azure SQL database with the exact connection string you're using in Azure. This will rule out any database-side issues, like incorrect credentials or server misconfiguration.

内容的提问来源于stack exchange,提问作者FindBSB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:06:04