读取Azure密钥库会引发异常:System.ExecutionEngineException:'引发了类型为'System.ExecutionEngineException'的异常。'

问题描述 投票:0回答:1

我正在尝试使用下面的代码从Azure密钥保管库读取值,但是它总是在第一次和第二次运行时都抛出异常以下。由于它是System.ExecutionEngineException: 'Exception of type 'System.ExecutionEngineException' was thrown.',因此无法处理(至少我知道)。

我的代码如下:

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;
    }
c# .net azure azure-web-sites azure-keyvault
1个回答
0
投票

我们不能确切地说在访问azure密钥库时抛出此异常。因为,当CLR中出现问题时,会抛出System.ExecutionEngineException。可能是之前发生的错误。我看到的唯一解决方案是将代码从起点重构到此点(在这里访问密钥库)。您可以通过here

对该问题进行深入了解
© www.soinside.com 2019 - 2024. All rights reserved.