IConfigurationBuilder Does not Contain .AddAzureKeyVault in 2.1
pakrym opened this issue · comments
From @eopeter on June 20, 2018 17:0
.AddAzureKeyVault was working in dotnet core 2.0 but not recognized in 2.1. I am using Microsoft.Extention.Configuration
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, builder) =>
{
var builderConfig = builder.Build();
**builder.AddAzureKeyVault($"https://{builderConfig["Vault"]}.vault.azure.net/",**
builderConfig["ClientId"],
builderConfig["ClientSecret"]);
})
.UseApplicationInsights()
.UseStartup<Startup>();
}
Copied from original issue: dotnet/core#1714
From @Petermarcu on June 21, 2018 20:43
@muratg should this get moved to an ASP.NET repo to track?
@eopeter, can you share your .csproj
file please?
This is the content of the .csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="2.3.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.0-preview1-final" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>
<ItemGroup>
<None Include="Views\Shared\_LayoutPartial.cshtml" />
<None Include="wwwroot\js\site.js" />
<None Include="wwwroot\js\site.min.js" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\ApplicationViewModels\" />
</ItemGroup>
</Project>
Microsoft.AspNetCore.App
doesn't include a reference to Microsoft.Extensions.Configuration.AzureKeyVault
like Microsoft.AspNetCore.All
did in 2.0.
Try adding
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.1.0" />
to your csproj.
That did it!!! Thanks!!
I have this same issue, cannot find .AddAzureKeyVault, here is my .csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<LangVersion>7.1</LangVersion>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win10-x64;ubuntu.16.10-x64</RuntimeIdentifiers>
<StartupObject />
<Configurations>Debug;Release;Staging;DebugStaging</Configurations>
</PropertyGroup>
<ItemGroup>
<Content Remove="appsettings.Debug.json" />
<Content Remove="appsettings.DebugStaging.json" />
<Content Remove="appsettings.Release.json" />
<Content Remove="appsettings.Staging.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.1.1" />
<PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="3.1.66" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.1" />
<PackageReference Include="MimeKit" Version="2.0.5" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.0" />
</ItemGroup>
<ItemGroup>
<None Include="appsettings.Debug.json">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>appsettings.json</DependentUpon>
</None>
<None Include="appsettings.Release.json">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>appsettings.json</DependentUpon>
</None>
<None Include="appsettings.DebugStaging.json">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>appsettings.json</DependentUpon>
</None>
<None Include="appsettings.Staging.json">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>appsettings.json</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<TransformOnBuild>true</TransformOnBuild>
</Content>
</ItemGroup>
</Project>
Any help appreciated
Nevermind, adding the version number to:
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.1" />
then close and reopen the solution + build solved it for me