【问题标题】:Azure KeyVault Config Builder connection string resulting in timeoutAzure KeyVault Config Builder 连接字符串导致超时
【发布时间】:2021-12-23 12:07:02
【问题描述】:

目前正在尝试使用配置构建器在我们的 .net 应用程序中填充我们的 web.config 连接字符串,这会导致超时。我关注了这个guide。我可以确认数据库的密码是正确的。我也已经尝试过确保通过 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>

有没有更好的方法可以诊断这里发生了什么?

【问题讨论】:

    标签: c# .net azure entity-framework azure-keyvault


    【解决方案1】:

    我让它工作了。不同之处在于,当我在应用服务部署中编辑要与 @Microsoft.KeyVault 机密引用一起使用的连接字符串时,与仅使用本地 web.config 中的 azure key vault config builder 相比。在前者中,我将 tcp:......, 1433 包含在数据源/服务器名称中,然后包含 id=id@server(即 sa@server.windows.net)作为 id。在我的本地 web.config 中,我删除了这些更改并成功了。

    【讨论】:

      猜你喜欢
      • 2011-10-07
      • 2019-09-29
      • 2017-09-29
      • 2022-10-20
      • 2021-03-02
      • 2019-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多