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

These changes allow Aspire service discovery to work in a hosted Blaz… #7162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BenjaminCharlton
Copy link

These changes allow Aspire service discovery to work with a hosted Blazor WebAssembly app.

It basically integrates my Nuget package Aspire4Wasm (source code here) into Aspire (with the addition of only 5 new classes and 2 interfaces, and changing none of the existing ones).

The changes allow an Aspire AppHost to define web APIs that a Blazor app can access, and pass that service discovery information to the app by writing to its appsettings.{environment}.json files.

These changes will not make the Aspire developer experience with Blazor totally seamless. For example, I'm still having difficulty with stand-alone Blazor WebAssembly apps, and I haven't figured out how to stop the app launching on a random port as well as the one specified in launchsettings.json. However, this is a step in the right direction and will help make Aspire a bit more Blazor-friendly. If you want to see what it does before accepting the changes, try the Nuget package Aspire4Wasm (version 3.0.0 at the time of writing).

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • [ x ] Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • [ x ] Yes
    • No
  • Did you add public API?
    • [ x ] Yes
      • If yes, did you have an API Review for it?
        • Yes
        • [ x ] No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • [ x ] Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • [ x ] No
  • Does the change require an update in our Aspire docs?
    • Yes
    • [ x ] No (The triple slash/XML remarks should be sufficient documentation but I'm happy to add more if needed.

@davidfowl
Copy link
Member

A change this big should be an issue with an API proposal and a design. That will dramatically increase the changes of it getting reviewed and aligned with a release.

@BenjaminCharlton
Copy link
Author

BenjaminCharlton commented Jan 20, 2025

Hi @davidfowl ! Thanks for your interest. I'm happy for you to guide me through that if that's what I need to do. It's my first time contributing to Aspire.

I saw a lot of issues already about getting Aspire to play nicely with Blazor (server, webassembly, hosted and standalone), or tangentially related to using Aspire with front end GUIs. People seem to agree that it has loads of potential! I wasn't sure another issue would be appreciated. Should we use an existing one?

I thought maybe, out of these open issues, the fourth one is pretty much exactly what my PR is about:

Shall we use that rather than open a fresh one? Do you have a template for an API proposal and design I can follow please?

@JJong-nl
Copy link

The a code example for setting the opening browser to a fixed port.

A TargetPort cannot be set from the launchSettings.
So after the launchSettings are retreived, change the endpoints TargetPort

#3145 (comment)

…or WebAssembly app. It basically integrates my Nuget package Aspire4Wasm into Aspire (with the addition of a few classes and changing none of the existing ones). The changes allow an Aspire AppHost to define the web API (or APIs) that a Blazor app should access, and to pass that service discovery information to the app by writing to its appsettings.json files. It does not make the developer experience with Blazor in Aspire totally seamless. For example, I'm still having difficulty with stand-alone Blazor WebAssembly apps, and I haven't figured out how to stop the app launching on a random port as well as the one specified in launchsettings.json. However, it is a big step in the right direction. If you want to see what it does before accepting the changes, please try the nuget package Aspire4Wasm (version 3.0.0 at the time of writing).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants