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