0

I created a simple Blazor WASM webapp using C# .NET5. It connects to some Functions which in turn get some data from a SQL Server database. I followed the tutorial of BlazorTrain: https://www.youtube.com/watch?v=5QctDo9MWps

Locally using Azurite to emulate the Azure stuff it all works fine. But after deployment using GitHub Action the webapp starts but then it needs to get some data using the Functions and that fails. Running the Function in Postman results in a 503: Function host is not running.

I'm not sure what I need to configure more. I can't find the logging from Functions. I use the injected ILog, but can find the log messages in Azure Portal.
In Azure portal I see my 3 GET functions, but no option to test or see the logging.

4
  • are you able to run the functions independently from postman or portal ? Commented Mar 26, 2021 at 15:50
  • @Aravind: Do you mean using the URL? No the same error. And I can't find how to run the functions using portal. Commented Mar 26, 2021 at 16:14
  • on the function app page click functions on the left menu and then click the appropriate function method and then click the Code+test and then use the test and run option . make sure the function has a valid consumption or app service plan and also if it does not have any errors during startup. Commented Mar 26, 2021 at 16:25
  • I don't have a separate function app. The functions are part of the Static Web App Commented Mar 26, 2021 at 16:46

1 Answer 1

0

With the help of @Aravid I found my problem.
Because I locally needed to tell my client the URL of the API I added a configuration in Client\wwwroot\appsettings.Development.json.
Of course this file doesn't get deployed.

After changing my code in Program.cs to:

  var apiAddress = builder.Configuration["ApiAddress"] ?? $"{builder.HostEnvironment.BaseAddress}/api/";
  builder.Services.AddHttpClient("Api",(options) => {
                options.BaseAddress = new Uri(apiAddress);
            });

My client works again.

I also added my SqlServer connection string in the Application Settings of my Static Web App and the functions are working as well.

I hope somebody else will benefit from this. Took me several hours to figure it out ;)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.