Skip to content

Add WithHttpsHealthCheck() to start template#8444

Merged
DamianEdwards merged 2 commits into
mainfrom
damianedwards/template-httphealthcheck
Mar 31, 2025
Merged

Add WithHttpsHealthCheck() to start template#8444
DamianEdwards merged 2 commits into
mainfrom
damianedwards/template-httphealthcheck

Conversation

@DamianEdwards

Copy link
Copy Markdown
Member

Description

Updates the starter template so that the app host health checks include checking the health checks endpoints of the two ASP.NET Core projects added via WithHttpsHealthChecks("/health").

As suggested here: #8139 (reply in thread)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • No
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

Copilot AI review requested due to automatic review settings March 31, 2025 17:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request updates the Aspire starter template so that the app host now includes health checks for both the API service and web frontend projects by using the WithHttpsHealthCheck extension with the endpoint "/health".

  • Added health check configuration for the API service project.
  • Added health check configuration for the web frontend project.
Comments suppressed due to low confidence (2)

src/Aspire.ProjectTemplates/templates/aspire-starter/9.2/Aspire-StarterApplication.1.AppHost/Program.cs:8

  • The health check addition for the API service is not covered by any tests. Consider adding tests to verify its functionality.
.WithHttpsHealthCheck("/health");

src/Aspire.ProjectTemplates/templates/aspire-starter/9.2/Aspire-StarterApplication.1.AppHost/Program.cs:12

  • The health check addition for the web frontend project is not covered by any tests. Consider adding tests to verify its functionality.
.WithHttpsHealthCheck("/health")

@davidfowl

Copy link
Copy Markdown
Contributor

Does this need to handle http and https?

@maddymontaquila

Copy link
Copy Markdown
Contributor

Maybe only add to 1 of them to make it more obvious what the behavior it enables is?

#endif
var apiService = builder.AddProject<Projects.GeneratedClassNamePrefix_ApiService>("apiservice");
var apiService = builder.AddProject<Projects.GeneratedClassNamePrefix_ApiService>("apiservice")
.WithHttpsHealthCheck("/health");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would adding a comment to explain what this is doing be overkill? ie "Telling Aspire dashboard to show health checks from '/health' endpoint"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like overkill, the method signature help tooltip thing should explain it well enough?

@DamianEdwards

Copy link
Copy Markdown
Member Author

Does this need to handle http and https?

The templates don't actually work without HTTPS out of the box today, they require manual changes. But, I should at least put the guard around this so that if you create it without HTTPS this calls the appropriate method.

@DamianEdwards DamianEdwards merged commit 6d444d1 into main Mar 31, 2025
@DamianEdwards DamianEdwards deleted the damianedwards/template-httphealthcheck branch March 31, 2025 20:39
@github-actions github-actions Bot locked and limited conversation to collaborators May 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants