Can't set secret and its value using Azure.Security.KeyVault.Secrets SDK
See original GitHub issueI’m using Azure.Security.KeyVault.Secrets v4.3.0 and the method SetSecretAsync of SecretClient. It’s failing with following error:
System.TypeInitializationException: "The type initializer for 'Azure.Security.KeyVault.Secrets.KeyVaultSecret' threw an exception." ---> System.IO.FileNotFoundException: "Could not load file or assembly 'System.Text.Encodings.Web, Version=4.0.5.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.\n"
--- End of inner exception stack trace ---
at at Azure.Security.KeyVault.Secrets.KeyVaultSecret.WriteProperties(Utf8JsonWriter json)
I’m using Visual Studio Community 2019 for Mac, Version 8.10.22 (build 11). The project is Azure Functions application. I’m debugging it locally using Azure Functions tools. I cleared up the NuGet cache, removed all stalled System.Text.Encodings.Web assemblies on my Mac.
Here is the list of references across 4 different projects within the solution that reference each other:
project 1:
<ItemGroup>
<PackageReference Include="Azure.Core" Version="1.24.0" />
<PackageReference Include="Azure.Security.KeyVault.Certificates" Version="4.3.0" />
<PackageReference Include="Azure.Security.KeyVault.Keys" Version="4.3.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.3.0" />
<PackageReference Include="FluentValidation" Version="10.4.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="10.4.0" />
<PackageReference Include="Microsoft.FeatureManagement" Version="2.5.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.24" />
<PackageReference Include="Azure.ResourceManager.KeyVault" Version="1.0.0-beta.6" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="9.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="AutoMapper" Version="10.1.1" />
</ItemGroup>
project 2:
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="3.1.23" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.13" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="2.4.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.1.0" />
</ItemGroup>
project 3:
<ItemGroup>
<PackageReference Include="Azure.Data.Tables" Version="12.5.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.9.0" />
</ItemGroup>
project 4:
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.Fluent" Version="1.38.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.20" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.20" />
<PackageReference Include="Azure.Identity" Version="1.6.0" />
<PackageReference Include="Azure.ResourceManager" Version="1.0.0-beta.8" />
</ItemGroup>
Project 4 from the list above has the code that is failing. It references project 1. Project 1 references project 3. Project 2 (main project) references project 4 and project 1.
Looks like some package is messing everything up or this is the bug in Azure.Security.KeyVault.Secrets. Do you have any guidance about Azure SDK on which versions of mentioned packages can be used together?
Thanks in advance.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
yeah, this was more than a year ago 😃 I bet we already migrated to a newer .NET version and newer runtime since then. I haven’t heard about such issues tbh. Let’s consider this as addressed. I will reach out if it is not.
Sorry, but this seems to have slipped through the cracks. Was this still a problem? Dependencies across the Azure Functions runtime, PowerShell support, etc., have all since been updated so I’m hopeful this is no longer a problem.