Discussion: How should we use service discovery in Blazor WASM? #582
Comments
I put a stripped-down WIP Blazor app here: https://github.com/seesharprun/blazortye |
Client-side apps are different due to being executed on the client. I think that you either have to request it from the orchestrator somehow or inject it at build time. Ideally, there would be an API endpoint which the client-side app would request configuration from. Tye could provide that endpoint. |
I found this while browsing NuGet: |
It would be great to get official guidance from Microsoft on best approach here. azsdke2e |
@RobertSundstrom hit the nail on the head here; either we need to inject it at build time, which requires knowing about a publicly exposed ingress endpoint, or setup a service/api. I'm not sure which solution is better here though. |
@jkotalik Excuse me for repeating myself: Just ask yourself: What would the Azure Team come up with. So that is why I believe that they would server the configuration just like you would a The cases might differ when you run standalone Blazor or hosted Blazor (or any other app type). I would probably implement it like this:
|
I ended up using ingress for this: So in my blazor app, I just need to bind to the same host that the blazor app is bound to. B/c of ingress it appears to be the same host to the blazor app.
|
I was building out a sample that I wanted to contribute via PR. The sample would have a Blazor WASM frontend and a simple Web API backend.
As with the angular sample, I was forced to hard-code the ports so I could know how to call the API on the back-end. The Blazor WASM project runs client-side, so it wouldn't have access to the server-side configuration settings unless I hosted it in an ASP.NET Core project complicating the sample.
I know hard-coding for client-side apps is the reality now, but is there any plans to ease this minor pain? I saw some issues mention generating constants use a source generator, but that didn't seem to be in progress.
BTW: The
GetServiceUri
extension method works well server-side and that was a great addition.The text was updated successfully, but these errors were encountered: