Reading Azure key vault throws exception: System.ExecutionEngineException: 'Exception of type 'System.ExecutionEngineException' was thrown.' RRS feed

  • Question

  • 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. As it is 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;

    Monday, May 4, 2020 5:11 PM

All replies

  • Are you running this code in local environment ? Have you tried running your code with DefaultAzureCredential instead of ClientSecretCredential to validate it in your local if it works fine ?  Please refer to this sample

    Monday, May 4, 2020 11:40 PM
  • Please let me know if you find above reply useful. If yes, do click on 'Mark as answer' link in above reply. This will help other community members facing similar query to refer to this solution. Thanks.
    Tuesday, June 2, 2020 6:29 PM