[英]Reading Azure key vault throws exception: System.ExecutionEngineException: 'Exception of type 'System.ExecutionEngineException' was thrown.'
I am trying to read the values from Azure Key vault using below code, but it always throws below exception at first time and second time it just runs fine.我正在尝试使用以下代码从 Azure 密钥库中读取值,但它总是第一次抛出异常,第二次运行正常。 As it is System.ExecutionEngineException: 'Exception of type 'System.ExecutionEngineException' was thrown.'
因为它是System.ExecutionEngineException: 'Exception of type 'System.ExecutionEngineException' was thrown.'
No way to handle it(at least I am aware).没有办法处理它(至少我知道)。
My code looks like:我的代码如下所示:
private Dictionary<string, string> GetCredentials()
{
string tenantId = "<TenantId>";
string clientId = "<ClientId>";
string clientSecret = "<ClientSecret>";
string vaultUrl ="<VaultUrl>";
SecretClient secretClient = new SecretClient(
new Uri(vaultUrl),
new ClientSecretCredential(tenantId, clientId, clientSecret)
);
var UserName = secretClient.GetSecret("UserName");
var Password = secretClient.GetSecret("Password");
var result = new Dictionary<string, string>
{
{UserName.Value.Value, Password.Value.Value}
};
return result;
}
We cannot exactly say that this exception is thrown while accessing the azure key vault.我们不能准确地说是在访问 azure 密钥保管库时引发了此异常。 Because, System.ExecutionEngineException
is thrown when there is an issue in CLR.因为,当 CLR 出现问题时,会引发System.ExecutionEngineException
。 might be an error that happen before.可能是之前发生的错误。 The only solution i see is to refactor your code from the starting point to this point(where you access key vault).我看到的唯一解决方案是将代码从起点重构到这一点(访问密钥库的位置)。 You can have an in-depth understanding about the issue over here你可以在这里深入了解这个问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.