Search code examples
c#azureblazorblazor-client-side

Unable to find files located in my root project folder when hosted on Azure


I tried to find files located in the root project of my Blazor Client WebAssembly project. While it works when executed locally on my computer, it doesn't work when hosted on Azure.

When executed locally, I got 1

When executed on Azure, I got 0 (no access denied errors of things like that)

To be more complete, I will have some files needed to fill an initial blank database.

If I cannot access files in the project folder, then I will go for a Blob Azure Storage. I would like to clarify that this is only a test project for myself.

enter image description here


Solution

  • The reason for this problem is that the TextFile.txt file was not included at the time of publication.

    Akos said is right. I am modifying the .csproj file to send out my answer. Can better help other users of the forum.

    You can paste code in your .csproj file.

    <Project Sdk="Microsoft.NET.Sdk.Web">
    
      <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
      </PropertyGroup>
      <ItemGroup>
        <ResolvedFileToPublish Include="TextFile.txt">
          <RelativePath>TextFile.txt</RelativePath>
        </ResolvedFileToPublish>
      </ItemGroup>
    </Project>
    

    Then you can deploy your app. You can find TextFile.txt under D:\home\site\wwwroot>.

    enter image description here