Skip to content
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

AspNetCore.HealthChecks.AzureSearch error #2302

Open
brett-wolf opened this issue Oct 2, 2024 · 1 comment
Open

AspNetCore.HealthChecks.AzureSearch error #2302

brett-wolf opened this issue Oct 2, 2024 · 1 comment

Comments

@brett-wolf
Copy link

I am attempting to health check an azure search using AspNetCore.HealthChecks.AzureSearch. I have set up the healthcheck correctly, I believe :

    .AddAzureSearch(setup: az => new AzureSearchOptions()
    {
        Endpoint = locationSearchOptions.ServiceUri,
        AuthKey = locationSearchOptions.ApiKey,
        IndexName = locationSearchOptions.IndexName

    }, name: "LocationAzureSearch");

I have checked that all the values being passed in are valid and not null, but running the health check, I get the following error:

[2024-10-02T19:47:43.213Z] Function 'Health', Invocation id '5e5ad236-076c-4889-8a85-0f724dffe679': An exception was thrown by the invocation.
[2024-10-02T19:47:43.214Z] Result: Function 'Health', Invocation id '5e5ad236-076c-4889-8a85-0f724dffe679': An exception was thrown by the invocation.
Exception: System.ArgumentNullException: Value cannot be null. (Parameter 'searchOptions.Endpoint')
[2024-10-02T19:47:43.214Z]    at System.ArgumentNullException.Throw(String paramName)
[2024-10-02T19:47:43.215Z]    at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
[2024-10-02T19:47:43.216Z]    at Guard.ThrowIfNull[T](T argument, Boolean throwOnEmptyString, String paramName) in /_/src/CallerArgumentExpressionAttribute.cs:line 47
[2024-10-02T19:47:43.217Z]    at HealthChecks.AzureSearch.AzureSearchHealthCheck..ctor(AzureSearchOptions searchOptions) in /_/src/HealthChecks.AzureSearch/AzureSearchHealthCheck.cs:line 18
[2024-10-02T19:47:43.218Z]    at HealthChecks.AzureSearch.DependencyInjection.AzureSearchHealthCheckBuilderExtensions.<>c__DisplayClass1_0.<AddAzureSearch>b__0(IServiceProvider sp) in /_/src/HealthChecks.AzureSearch/DependencyInjection/AzureSearchHealthCheckBuilderExtensions.cs:line 39
[2024-10-02T19:47:43.218Z]    at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.RunCheckAsync(HealthCheckRegistration registration, CancellationToken cancellationToken)
[2024-10-02T19:47:43.219Z]    at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.RunCheckAsync(HealthCheckRegistration registration, CancellationToken cancellationToken)
[2024-10-02T19:47:43.220Z]    at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.CheckHealthAsync(Func`2 predicate, CancellationToken cancellationToken)
[2024-10-02T19:47:43.221Z]    at HubCustomerCore.Function.Functions.HealthChecks.HealthCheck.RunWithApiKeyAuth(HttpRequest req) in C:\Users\29T3\Source\Repos\HubCustomerCore\HubCustomerCore.Function\Functions\HealthChecks\HealthCheck.cs:line 67
[2024-10-02T19:47:43.222Z]    at HubCustomerCore.Function.DirectFunctionExecutor.ExecuteAsync(FunctionContext context) in C:\Users\29T3\Source\Repos\HubCustomerCore\HubCustomerCore.Function\obj\Debug\net8.0\Microsoft.Azure.Functions.Worker.Sdk.Generators\Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionExecutorGenerator\GeneratedFunctionExecutor.g.cs:line 52
[2024-10-02T19:47:43.222Z]    at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13
[2024-10-02T19:47:43.223Z]    at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 48
[2024-10-02T19:47:43.224Z]    at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 91
Stack:    at System.ArgumentNullException.Throw(String paramName)
[2024-10-02T19:47:43.225Z]    at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
[2024-10-02T19:47:43.226Z]    at Guard.ThrowIfNull[T](T argument, Boolean throwOnEmptyString, String paramName) in /_/src/CallerArgumentExpressionAttribute.cs:line 47
[2024-10-02T19:47:43.227Z]    at HealthChecks.AzureSearch.AzureSearchHealthCheck..ctor(AzureSearchOptions searchOptions) in /_/src/HealthChecks.AzureSearch/AzureSearchHealthCheck.cs:line 18
[2024-10-02T19:47:43.228Z]    at HealthChecks.AzureSearch.DependencyInjection.AzureSearchHealthCheckBuilderExtensions.<>c__DisplayClass1_0.<AddAzureSearch>b__0(IServiceProvider sp) in /_/src/HealthChecks.AzureSearch/DependencyInjection/AzureSearchHealthCheckBuilderExtensions.cs:line 39
[2024-10-02T19:47:43.228Z]    at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.RunCheckAsync(HealthCheckRegistration registration, CancellationToken cancellationToken)
[2024-10-02T19:47:43.229Z]    at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.RunCheckAsync(HealthCheckRegistration registration, CancellationToken cancellationToken)
[2024-10-02T19:47:43.230Z]    at Microsoft.Extensions.Diagnostics.HealthChecks.DefaultHealthCheckService.CheckHealthAsync(Func`2 predicate, CancellationToken cancellationToken)
[2024-10-02T19:47:43.231Z]    at HubCustomerCore.Function.Functions.HealthChecks.HealthCheck.RunWithApiKeyAuth(HttpRequest req) in C:\Users\29T3\Source\Repos\HubCustomerCore\HubCustomerCore.Function\Functions\HealthChecks\HealthCheck.cs:line 67
[2024-10-02T19:47:43.232Z]    at HubCustomerCore.Function.DirectFunctionExecutor.ExecuteAsync(FunctionContext context) in C:\Users\29T3\Source\Repos\HubCustomerCore\HubCustomerCore.Function\obj\Debug\net8.0\Microsoft.Azure.Functions.Worker.Sdk.Generators\Microsoft.Azure.Functions.Worker.Sdk.Generators.FunctionExecutorGenerator\GeneratedFunctionExecutor.g.cs:line 52
[2024-10-02T19:47:43.232Z]    at Microsoft.Azure.Functions.Worker.OutputBindings.OutputBindingsMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\src\DotNetWorker.Core\OutputBindings\OutputBindingsMiddleware.cs:line 13
[2024-10-02T19:47:43.233Z]    at Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore.FunctionsHttpProxyingMiddleware.Invoke(FunctionContext context, FunctionExecutionDelegate next) in D:\a\_work\1\s\extensions\Worker.Extensions.Http.AspNetCore\src\FunctionsMiddleware\FunctionsHttpProxyingMiddleware.cs:line 48
[2024-10-02T19:47:43.234Z]    at Microsoft.Azure.Functions.Worker.FunctionsApplication.InvokeFunctionAsync(FunctionContext context) in D:\a\_work\1\s\src\DotNetWorker.Core\FunctionsApplication.cs:line 91.
  • .NET Core version : net8.0
  • Healthchecks version : 8.0.1
  • Operative system: Windows 11 Enterprise
  • Others:
@brett-wolf
Copy link
Author

Resolved this. I was not passing in an Action :

     .AddAzureSearch(setup: new Action<AzureSearchOptions>(obj =>
     {
         obj.Endpoint = customerSearchOptions.ServiceUri;
         obj.AuthKey = customerSearchOptions.ApiKey;
         obj.IndexName = customerSearchOptions.IndexName;
     }), name: "CustomerAzureSearch")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant