【发布时间】:2023-03-19 05:32:01
【问题描述】:
在开发模式下,在我的本地机器VS2017 15.7.5上,我正在使用
- Asp.Net MVC 核心 2.1
- Azure KeyVault 3.0.0
- AppAuthentication 1.1.0-预览版
我已经建立了一个单独的项目,用于从保险库中获取机密、添加日志记录和其他内容。我从我的 MVC 项目中引用了该项目。
当我启动网站时,我得到:
Exception thrown: 'System.IO.FileLoadException' in Microsoft.AspNetCore.Hosting.dll
我无法追踪。
{编辑:我发现了这个,它在CSPROJ 中是一个不好的参考。其他一切都保持不变。}
我像这样实例化AzureServiceTokenProvider:
_provider = new AzureServiceTokenProvider();
_client = new KeyVaultClient(new KeyVaultClient
.AuthenticationCallback(_provider.KeyVaultTokenCallback));
然后我像这样使用它:
try
{
var secretBundle = await _client
.GetSecretAsync(_config[$"{SecretUrlsKey}:{secretName}"])
.ConfigureAwait(false);
Debug.WriteLine("Secret retrieved from vault ...");
_secretCache.Add(secretName, secretBundle.Value);
return secretBundle?.Value;
}
catch (Exception e)
...
然后我收到一连串错误(没有一个错误返回到我的代码中)。像这些:
Exception thrown: 'Microsoft.Rest.TransientFaultHandling.HttpRequestWithStatusException' in Microsoft.Rest.ClientRuntime.dll
Exception thrown: 'Microsoft.Rest.TransientFaultHandling.HttpRequestWithStatusException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProviderException' in Microsoft.Azure.Services.AppAuthentication.dll
Exception thrown: 'Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProviderException' in System.Private.CoreLib.dll
Exception thrown: 'Microsoft.Azure.Services.AppAuthentication.AzureServiceTokenProviderException' in System.Private.CoreLib.dll
最终我得到了我正在寻找的价值,但这似乎有点不稳定。
FWIW,我将它部署到 Azure 的成功率为零。
有人对此有任何想法吗?
TIA
【问题讨论】:
-
我忘了提到我是如何修复文件未找到问题的。这样做:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional gacutil -if Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.8.0.dll
标签: azure-keyvault