如何使用 Entity Framework 连接字符串来使用 Azure Key Vault

How to user Azure Key Vault with an Entity Framework connection string

我正在尝试通过 Azure Key Vault 和这个 guide 加密我的应用服务的连接字符串,但我收到以下错误: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid. 我最初认为这是因为字符串中的 " 字符,所以我用实际的 " 替换了那些。现在我想这可能是因为它不是一个普通的连接字符串,而是一个 db first entity framework 一个,如图所示: connectionString="metadata="res://*/Models.{Project}.csdl|res://*/Models.{Project}.ssdl|res://*/Models.{Project}.msl";provider=System.Data.SqlClient;provider connection string="data source={datasource};initial catalog={db};persist security info=True;user id={id};password={password};MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />

(括号内的值只是为了隐藏敏感信息)。我如何使用 Azure Key Vault 让它工作?

请检查以下可能解决问题的方法。

1。配置文件可能有 " 而不是 ",.Azure 中的网站必须将 "e 值从连接 string.Also 更改为 检查它是否在门户中正确配置。

(或)

2。与尝试 1 一起,select“自定义”类型的连接字符串而不是“SQL 服务器”或“SQL azure”(如提供的 link 所示)Entity Framework 在应用服务中配置连接字符串时。

我想通了。连接字符串中的唯一引号必须来自提供程序连接字符串=之后,并且最重要的是它们必须是单引号,即'.