I have added to project (WebApi .net 4.7) KeyVault as connected service. So far so good, it just have hardcoded KeyVault name in web.config. Then, I have added
Microsoft.Configuration.ConfigurationBuilders.Environment
to project, to read KeyVaultName from local environment. Now web.config looks like this:
<configBuilders>
<builders>
<add name="Environment" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="AzureKeyVault" vaultName="keyvault-name" type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure, Version=1.0.0.0, Culture=neutral" /></builders>
</configBuilders>
The issue is, that after upgrading Microsoft.Configuration.ConfigurationBuilders.Azure
to 2.0 Visual Code seems to not connect to azure KeyVault. I am following this guide https://peterbozso.com/2019/03/18/key-vault-asp-net.html Am I missing something? Or this version won't work in local envrionment. I am guessing that when deploying api with packeage ConfigBuilder.Azure in 2.0 will work, just we want to have it working localy as well.
We need to have this in version 2.0 because it allows reading varabiles from envrionment (https://github.com/aspnet/MicrosoftConfigurationBuilders#appsettings-parameters)
This is web.config after upgarding ConfigBuilder.Azure to 2.0.
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<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="Environment" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="AzureKeyVault" vaultName="keyvault-name" type="Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</builders>
</configBuilders>
<appSettings configBuilders="Environment, AzureKeyVault">
<add key="someKey" value="seomValue" />
</appSettings>
I was thinking that is was issue that I was using VS2017, now switched to VS2019 with no difference.