azure - 将 Azure API 应用程序移动到自定义域后无法访问 Azure SQL 数据库

标签 azure ssl dns azure-sql-database azure-api-apps

我将我的 API 从免费计划中移出 app service基本计划app servicecustom domainSSL certificate .

1) 我看到我的 API 应用程序的状态是“正在运行”,身份验证 (AAD) 工作正常

2) 如果我打开它的 api 定义(即 */swagger/docs/v1)它正在工作

3) 如果我尝试不尝试访问后端 Azure sql db 的请求,那么它工作正常

4) 如果我使用调用后端 Azure SQL 数据库的请求(它在将 API 移动到自定义域之前有效),它会失败并出现此错误:

{"The underlying provider failed on Open., StackTrace: at System.Data.Entity.Core.EntityClient.EntityConnection.Open()\r\n at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)\r\n at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass651.b__63()\r\n at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func1 operation)\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteStoreQueryReliably[TElement](String commandText, String entitySetName, ExecutionOptions executionOptions, Object[] parameters)\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteStoreQuery[TElement](String commandText, ExecutionOptions executionOptions, Object[] parameters)\r\n at System.Data.Entity.Internal.InternalContext.<>c__DisplayClass141.b__13()\r\n at System.Data.Entity.Internal.LazyEnumerator1.MoveNext()\r\n at System.Collections.Generic.List1..ctor(IEnumerable1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)\r\n
at P..Repositories.DataAccessLayer.DbContexts.P..DbContext.GetP..Dtos()\r\n at P..Repositories.Repositories.P..Repository.P..Repository..ctor()\r\n at P..API.Controllers.A..Controller.Get()"}]}

到目前为止我发现的唯一一件事表明我的 API 由于防火墙规则而无法访问 Azure SQL,但这听起来不是一个选项,因为我刚刚为我的应用程序分配了一个自定义域,我相信它是在 Azure 中的同一个“位置”……到目前为止,在将 API 迁移到自定义域时,我还没有找到有关 Azure SQL 数据库连接的任何建议……

有什么想法吗?

最佳答案

事实证明,出于某种奇怪的原因,在移动到自定义域 - 发布设置后,AzureDatabase 连接字符串不存在(接缝如“生成的”名称 -> 添加了 Api 名称后缀 _db) 数据库名称。当我将它更改为真实的数据库名称时,一切又开始工作了......

附言我想取消选中“在运行时使用此连接字符串(更新目标 web.config)”会得到相同的结果,因为 web.config 拥有正确的连接字符串。

enter image description here

关于azure - 将 Azure API 应用程序移动到自定义域后无法访问 Azure SQL 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42677120/

相关文章:

azure - 为什么 Azure ML studio 中用于数据漂移监控的字段 "compute target"仍然为空,而我有一个计算实例?

azure - 无法从 azure 自动化运行手册启动 Azure 流分析?

postgresql - azure + postgresql : How to fix error: Unable to connect to server: server closed the connection unexpectedly

google-app-engine - Google App Engine - Google 用户服务是否等于 SSL?

Java:SSL 身份验证/SSL 调试问题

dns - Kerberos 完全限定域名

c - 为什么设置 AI_PASSIVE 时 getaddrinfo() 返回第一个 IPv4 而不是 IPv6?

azure - 在函数应用程序中,比例单位是函数还是应用程序?

php - 如何处理 Laravel 的 SMTP 驱动程序中的自签名 TLS 证书?

.NET DNS 类 powershell 后台作业可能吗?