gpt4 book ai didi

asp.net-mvc - AzureKeyVault ConfigurationBuilder 中的 connectionString 属性是什么样的?

转载 作者:行者123 更新时间:2023-12-05 01:16:31 24 4
gpt4 key购买 nike

我正在尝试在 .NET 4.7.1 MVC 应用程序中使用新的 AzureKeyVault ConfigurationBuilder,但在本地运行时不断出现配置错误:

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: An error occurred loading a configuration file: One or more errors occurred.

Source Error:


Line 13: </builders>
Line 14: </configBuilders>
Line 15: <appSettings configBuilders="AzureKeyVault">
Line 16: <add key="webpages:Version" value="3.0.0.0" />
Line 17: <add key="webpages:Enabled" value="false" />

在创建新的 .NET Framework 4.7.1 ASP.NET MVC Web 项目后,我向 Azure Key Vault 添加了一个连接服务,并以现有的保管库为目标。然后我的 web.config 看起来包含了这个部分:

<configuration>
<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="my-test-keyvault" connectionString="" type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure, Version=1.0.0.0, Culture=neutral" vaultUri="https://WebApplication1-12-kv.vault.azure.net" />
</builders>
</configBuilders>
<appSettings configBuilders="AzureKeyVault">
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.1" />
<httpRuntime targetFramework="4.7.1" />

我一直在 Internet 上搜索,试图找到 connectionString 应该是什么样子的示例,但我没有取得任何成功。文档指出:

The vaultName is required. The other attributes allow you some manual control about which vault to connect to, but are only necessary if the application is not running in an environment that works magically with Microsoft.Azure.Services.AppAuthentication. The Azure Services Authentication library is used to automatically pick up connection information from the execution environment if possible, but you can override that feature by providing a connection string instead.

这里有什么建议或指示吗?谢谢。

最佳答案

链接文章 (Announcing .NET 4.7.1 Tools for the Cloud) 中链接的文档已过期。 AzureKeyVaultConfigBuilder 类上没有 clientIdclientSecret 属性。

但是有一个 connectionString 属性。本文详细介绍了如何在本地运行时构建该连接字符串:Service-to-service authentication to Azure Key Vault using .NET .

这是对我有用的方法:

RunAs=App;AppId={AppId};TenantId={TenantId};AppKey={ClientSecret}

所有这三个值(AppId、TenantId 和 AppKey)都在 Azure 中应用程序的 AD 条目中可用。

关于asp.net-mvc - AzureKeyVault ConfigurationBuilder 中的 connectionString 属性是什么样的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53383511/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com