Add Azure function app project with test function

This commit is contained in:
2024-03-07 22:22:32 +00:00
parent 00417da7f9
commit aeb359506d
13 changed files with 425 additions and 3 deletions

View File

@@ -0,0 +1,23 @@
@page "/contact"
@inject HttpClient HttpClient
@if (!string.IsNullOrWhiteSpace(apiResponse))
{
<p class="text-2xl">Response from Azure Function API: @apiResponse</p>
}
@code {
private string apiResponse = "";
protected override async Task OnInitializedAsync()
{
var response = await HttpClient.GetStringAsync("/api/Function1");
if (!string.IsNullOrWhiteSpace(response))
{
apiResponse = response;
}
}
}

View File

@@ -7,8 +7,11 @@ var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
var apiBase = builder.Configuration["ApiBase"]
?? throw new ArgumentException("API base address not found in config.");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(apiBase) });
builder.Services.AddSingleton<ITypewriterNotificationService, TypewriterNotificationService>();
await builder.Build().RunAsync();
await builder.Build().RunAsync();

View File

@@ -0,0 +1,5 @@
{
"navigationFallback": {
"rewrite": "/index.html"
}
}

View File

@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ApiBase": "http://localhost:7071"
}