waf*_*ers 10 azure azure-web-app-service blazor blazor-client-side blazor-webassembly
问题出在客户端appsettings.json
appsettings.json位于目录内wwwroot。可以在应用程序内访问该文件,但是该设置不能被应用程序服务的 Azure Portal 应用程序设置覆盖。这意味着,在将应用程序部署到 Web 应用服务上的 Azure 门户中后,我的配置设置不适用于应用程序设置的变量。
这是 中的代码Progam.cs,它工作正常并从文件中读取配置,但忽略 Azure 上的 Web 应用服务的配置设置。
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
//Add a named httpClient and set base Address and Default Request Headers
builder.Services.AddHttpClient("SOME_WEB_URL", client => // SOME_WEB_URL is defined in the appsettings.json or in the Azure App Service configuration (Application Settings)
{
client.BaseAddress = new Uri(builder.Configuration["sbformsapi"]);
});
//Add a named httpClient and set base Address and Default Request Headers
builder.Services.AddHttpClient("WEB_APP_API", client => // WEB_APP_API is defined in the
{
client.BaseAddress = new Uri(builder.Configuration["sbwebappapi"]);
});
builder.Services.AddAuthorizationCore();
....
await builder.Build().RunAsync();
}
Run Code Online (Sandbox Code Playgroud)
有人可以指导我怎样才能
我在这里谈论应用程序设置(如图所示)...
目前应用程序设置仅适用于与 Blazor 应用程序关联的后端 API(假设使用静态应用程序?)。
https://learn.microsoft.com/en-gb/azure/static-web-apps/application-settings
| 归档时间: |
|
| 查看次数: |
2515 次 |
| 最近记录: |