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

As of dotnet core 3.1, AddHealthChecks has become incompatible with Azure Functions apps #2846

Closed
danielearwicker opened this issue Jan 10, 2020 · 2 comments

Comments

@danielearwicker
Copy link

Describe the bug

We use Azure functions dependency injection, and we call AddHealthChecks() on the service collection.

We then have our own /health function endpoint that injects HealthCheckService and returns the UIHealthReport when requested.

But having upgraded to dotnet core 3.1, this seems to fail a new validation check, described in PR comment as "Adding breaking changes/compatibility analysis"

It lists 6 implementations of IHostedService that are expected, plus 4 more that are optional. If it finds any others, it throws an exception. i.e. this is now a closed system.

The AddHealthChecks() method registers an IHostedService called HealthCheckPublisherHostedService. It attempts to extend what is now closed, and so the validation check throws during startup.

NB. If I add this cursed line of code to knock out the offending registration, it makes the validation happy:

services.Remove(services.Single(s => s.ImplementationType?.Name == "HealthCheckPublisherHostedService"));

(I have to compare the name as a string because the class is internal.) And then our /health function endpoint responds with healthy (2) but I don't know if it's actually doing any healthchecks anymore.

Is there a "right" way to do this now? Looks like this extension now breaks some fundamental assumption recently adopted by the WebJobs/AF hosting code.

To Reproduce

Attempt to use AddHealthChecks() inside Azure Functions service collection registration. It throws the new validation exception during startup.

Expected behavior

The healthcheck capability works, as in 2.x.

@rynowak
Copy link
Member

rynowak commented Jan 17, 2020

Hi @danielabbatt - have you tried reporting this on azure/azure-functions-host ?

This is their code that's causing the issue.

@danielearwicker
Copy link
Author

@rynowak (that's a different Daniel). I already notified them, see link above. It's not so much their code causing the issue. They've merely added a check to make explicit that I've been using an unsupported scenario up to now and there's nothing I can do about that.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants