c# - Azure KeyVault Config Builder 连接字符串导致超时
问题描述
目前正在尝试使用配置构建器在我们的 .net 应用程序中填充我们的 web.config 连接字符串,这会导致超时。我按照这个指南。我可以确认数据库的密码是正确的。我也已经尝试过确保通过 Azure CLI 登录。这无济于事。我还要注意我们在数据库中使用 vpn。
错误
SqlException: Connection Timeout Expired. The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement. This could be because the pre-login handshake failed or the server was unable to respond back in time. The duration spent while attempting to connect to this server was - [Pre-Login] initialization=356; handshake=14649;
System.Data.EntityException: 'The underlying provider failed on Open.'
Web.config 文件:
<configSections>
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
</configSections>
<configBuilders>
<builders>
<add name="AzureKeyVault" vaultName="{vaultname}" type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /></builders>
</configBuilders>
<connectionStrings configBuilders="AzureKeyVault">
<add name="Entities" connectionString="" providerName="System.Data.EntityClient" />
<add name="ADConnectionString" connectionString="LDAP://52.157.144.83:389/DC=INFORMATIONSECURITYTOOLKIT,DC=Local" />
</connectionStrings>
有没有更好的方法可以诊断这里发生了什么?
解决方案
我让它工作了。不同之处在于,当我在应用服务部署中编辑要与 @Microsoft.KeyVault 机密引用一起使用的连接字符串时,与仅使用本地 web.config 中的 azure key vault config builder 相比。在前者中,我将 tcp:......, 1433 包含在数据源/服务器名称中,然后将 id=id@server(即 sa@server.windows.net)包含在 id 中。在我的本地 web.config 中,我删除了这些更改,并且成功了。
推荐阅读
- node.js - React Native 和 CSV 有可能吗?
- html - justify-content(flex-end; 对); 属性不工作
- selenium - 如何使用 Selenium 手动和自动查看 Chrome 浏览器存储的本地缓存文件?
- php - 从函数返回的 PHP 对象为空
- c - 如何在循环中使用 sscanf 处理错误以从标准输入获取输入?
- javascript - Javascript 我可以获取 Filelist 但我不能获取文件
- python - Beautifulsoup - 在页面源中找不到元素(href)
- swiftui - SwiftUI 中带有强密码建议的奇怪行为
- ios - 我可以将 creationRequestForAssetFromVideo 用于远程 URL 吗?
- image - 当我想从存储中读取多个文件时,onActivityResult 怎么样