将 ASP.NET Core Web API 部署到 Azure - 使用 Azure Key Vault 和 SQL 数据库依赖项

Deploying ASP.NET Core Web API to Azure - with Azure Key Vault and SQL Database dependency

我能够将 Web API 部署到 Azure。我必须在部署之前为 'Azure Key Vault'、'Azure SQL DB' 和 'Microsoft Identity platform' 配置,因为它们是依赖项。

我配置了 Azure Key Vault 并在为 SQL 数据库配置时,我选择了将连接字符串值保存在 'Azure Key Vault' 中而不是 'Azure app settings' 中的选项(请参见下面的屏幕截图)。

当我为 'Microsoft identify platform' 按配置时,页面显示加载符号但从未完成,也没有显示任何租户 ID 或配置详细信息。请看下面的截图。

所以我不得不暂时忽略配置 Microsoft Identity Platform。

我能够将应用程序部署到 Azure,但是当我尝试访问 Azure 端点时,出现错误

HTTP ERROR 500 (Trouble retrieving data from database).

访问 Azure 端点时记录以下文件消息:

An error occurred using the connection to database 'databasename' on server 'servername'.

An exception occurred while iterating over the results of a query for context type 'ItemApp.Infrastructure.Repository.ItemDBContext'. Microsoft.Data.SqlClient.SqlException (0x80131904):
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections...

谁能指出我哪里出错了?提前致谢。

  1. 检查您的数据库引擎是否可以处理远程连接:
  • 开始 > 所有程序 > SQL Server 2005 > 配置工具 > SQL 服务器表面区域配置

  • 单击服务和连接的外围应用配置

  • Select 有问题的实例 > 数据库引擎 > 远程连接

  • 启用本地和远程连接

  • 重启实例

  1. 检查您的SQL服务器服务是否正常,运行是否正常:
  • 转到所有程序 > Microsoft SQL Server 2008 > 配置工具 > SQL 服务器配置管理器 > SQL 服务器服务
  • 检查以确保 SQL 服务器服务状态为 运行ning。
  • 此外,请确保您的远程服务器在同一网络中。
  • 运行 sqlcmd -L 以确定您的服务器是否包含在您的网络列表中。
  1. 您可能需要在防火墙上为您正在使用的 SQL 服务器实例和端口创建例外:
  • 开始 > 运行 > Firewall.cpl

  • 单击例外选项卡

  • 添加 sqlservr.exe(通常位于 C:\Program Files (x86)\Microsoft SQL Server\MSSQL.x\MSSQL\Bin,检查您的安装 实际文件夹路径)和端口(默认为 1433)

  • 同时检查您的连接字符串

请检查 MSFT 文档以解决错误:Here