Current setup
- Blazor Web App (interactive server)
- .Net 8 runtime
- Zip deployment into azure web app
- Azure web app operating system is linux
The issue
So after starting the azure web app I can see following exception in the log stream:
Unhandled exception. System.ArgumentException: The path must be absolute. (Parameter 'root')
at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.<>c.<UseStaticWebAssetsCore>b__1_0(String contentRoot)
at Microsoft.AspNetCore.StaticWebAssets.ManifestStaticWebAssetFileProvider..ctor(StaticWebAssetManifest manifest, Func`2 fileProviderFactory)
at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssetsCore(IWebHostEnvironment environment, Stream manifest)
at Microsoft.AspNetCore.Hosting.StaticWebAssets.StaticWebAssetsLoader.UseStaticWebAssets(IWebHostEnvironment environment, IConfiguration configuration)
at Microsoft.AspNetCore.Builder.ConfigureWebHostBuilder.ConfigureAppConfiguration(Action`2 configureDelegate)
at Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.UseStaticWebAssets(IWebHostBuilder builder)
at MyWebApp.Program.Main(String[] args) in D:a1ssrcMyWebAppProgram.cs:line 28
I did add the line
builder.WebHost.UseStaticWebAssets();
as this fixed another issue I had before, where the web app could not load any file from wwwroot directory.
What I have already tried
I did try and set WebApplicationOptions manually, giving a value for “WebRootPath”:
var builder = WebApplication.CreateBuilder(new WebApplicationOptions
{
Args = args,
WebRootPath = @"C:homesitewwwroot"
});
Idea was to give a rooted path as I did have a look into the implementation of UseStaticWebAssets() and saw that there is a check called Path.IsPathRooted(root), checking for a path starting with backslash or a local drive name (e.g. C:). But that caused the exception:
Unhandled exception. System.UnauthorizedAccessException: Access to the path '/home/site/wwwroot/C:homesitewwwroot' is denied.
which makes sense as the path is absolutely weird. I have also observed that the args parameter from main function:
void Main(string[] args)
is empty. I am not sure if this behavior is correct as we give the args as parameter into the CreateBuilder function:
var builder = WebApplication.CreateBuilder(args);
I also published my blazor app into a web app hosted on windows and there the app runs fine without any issue.
Updates on comments
My zip file is created in a build pipeline (based on yaml file) and released via release pipeline in azure devops.
My wwwroot folder contains only one stylesheet and one javascript file.
Questions
- Why do I get the exception: The path must be absolute. (Parameter ‘root’) in a linux hosted web app?
- What is the difference in hosting on linux and windows with regards to run the app?
- If the root parameter have to be set, how do I do that?
11