Sukhi
Sukhi

Reputation: 45

How to add HealthChecks for AzureKeyVault health status

I was trying to add HealthChecks for AzureKeyVault to my project and added following nuget package for that :

<PackageReference Include="AspNetCore.HealthChecks.AzureKeyVault" Version="6.0.2" />

And in code, added following :

var url = "https://123456.com";
    builder.Services
        .AddHealthChecks()
        .AddAzureKeyVault(new Uri(url), keyVaultCredential,
                         options => { }, "AKV", HealthStatus.Unhealthy,
                         tags: new string[] { "azure", "keyvault", "key-vault", "azure-keyvault" });

But issue is, its showing healthy for each and every URL, just it should be proper URL. and even in keyVaultCredential, if some random values are added, it showing status healthy.

Do some one know, how can use this HealthCheck

Upvotes: 0

Views: 2845

Answers (2)

user19327841
user19327841

Reputation: 21

I have the same problem, I found we need to add at lease one key vault secret in the opts to make it work. e.g. options => { options.AddSecret("SQLServerConnection--connectionString");}

Upvotes: 2

kavya Saraboju
kavya Saraboju

Reputation: 10831

  • Please check if there are any restrictions in knowing the health status of azure resources or with the use of this library in your company VPN network .
  • Try the same in different network to check if the cause is network issue or VPN
  • Try with debugging tools to capture the traffic to verify and see response.

References:

  1. AzureKeyVault health check always returns "healthy" (github.com)
  2. AspNetCore.Diagnostics.HealthChecks

Upvotes: 1

Related Questions