-
Notifications
You must be signed in to change notification settings - Fork 801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure Key Vault Health check package and Unit tests project #19
Conversation
@@ -77,11 +80,12 @@ | |||
<HealthCheckDynamoDb>2.2.0</HealthCheckDynamoDb> | |||
<HealthCheckDocumentDb>2.2.0</HealthCheckDocumentDb> | |||
<HealthCheckAzureStorage>2.2.0</HealthCheckAzureStorage> | |||
<HealthCheckAzureServiceBus>2.2.0</HealthCheckAzureServiceBus> | |||
<HealthCheckAzureServiceBus>2.2.1</HealthCheckAzureServiceBus> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why a new version on service bus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because health checks contructor validations changed. It does not make sense to check only for null and not for empty string when initializing configuration towards an azure service
|
||
public AzureKeyVaultHealthCheck(AzureKeyVaultOptions keyVaultOptions) | ||
{ | ||
if (string.IsNullOrEmpty(keyVaultOptions.KeyVaultUrlBase)) throw new ArgumentNullException(keyVaultOptions.KeyVaultUrlBase); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add backets
} | ||
public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) | ||
{ | ||
string currentSecret = string.Empty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var
} | ||
|
||
return HealthCheckResult.Healthy(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove blank lines
return new HealthCheckResult(context.Registration.FailureStatus, exception: secretException); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank lines
string name = default, HealthStatus? failureStatus = default, IEnumerable<string> tags = default) | ||
{ | ||
var azureKeyVaultOptions = new AzureKeyVaultOptions(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line
@@ -13,8 +13,11 @@ public class AzureEventHubHealthCheck | |||
private readonly string _eventHubName; | |||
public AzureEventHubHealthCheck(string connectionString, string eventHubName) | |||
{ | |||
_connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString)); | |||
_eventHubName = eventHubName ?? throw new ArgumentNullException(nameof(eventHubName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably mix features on different package is not a good idea for tracking project. Can you split in two different pull requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New tests can't pass without this changes to the package. :/
|
||
registration.Name.Should().Be("azurekeyvault"); | ||
check.GetType().Should().Be(typeof(AzureKeyVaultHealthCheck)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank lines
|
||
registration.Name.Should().Be("azurequeue"); | ||
check.GetType().Should().Be(typeof(AzureServiceBusQueueHealthCheck)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank lines
{ | ||
var services = new ServiceCollection(); | ||
services.AddHealthChecks() | ||
.AddAzureServiceBusQueue("", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use string.empty
Hi Carlos, Some items to review:
|
99e8b44
to
560b44a
Compare
What about checking also keys that should exist? |
That is on the PR as well. Using the AddSecret fluent api |
I was talking about KeyVault encryption keys - it's a different feature of KeyVault. I looked on the code, look like it's not checked... |
That's not added. The idea was checking the existing secrets that the application might need. Feel free to add it if you consider :) |
Can I add it to the existing PR? Or on a different one? |
You can use the existing one |
How can I build the project on mac? Should I set env var like |
Hi @omerlh Right now on master, you can create a new PR for new features if you want! |
Thanks for this, PR is merged on master with some minor details |
Azure Key Vault health check that allows to configure a secret collection to be verified against the Azure Service
Usage:
Default usage with Managed Service Identity:
Usage usage client id and client secret:
Sample error for a not found secret using UI.Client response writer