Danielku15
Danielku15

Reputation: 1520

Azure App Service cannot access files and therefore not even load Assemblies

I am currently facing a really strange issue when deploying my Web Application as app service. And I am not sure what I am doing wrong.

My setup

I have an ASP.net core 2.2 (netstandard libraries) website running under .net 4.8 Framework due to certain dependencies. The application also runs as 64bit app service.

My Web.config configures the ANCM to run the output executable as OutOfProcess:

<?xml version="1.0" encoding="utf-8"?>
<configuration>    
    <system.webServer>
        <handlers>
            <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
        </handlers>
        <aspNetCore processPath=".\MyWebsite.exe" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
    </system.webServer>
</configuration>

This setup is working fine when deploying the application into a local IIS.

My problem

When deploying the same application to Azure as App Service on startup the Application claims it cannot load some assemblies. There are FileNotFoundExceptions thrown and FusionLog errors stating 0x80070002 Failed to complete setup of assembly.

After long investigations I could narrow down the issue to one major issue:

The MyWebsite.exe is not allowed to read any data from the files in C:\home\site\wwwroot where the website is deployed in Azure. I could proof this by trying to simply read any file which is there in the working directory (like the exe.config sitting beside the exe).

Also in the FusionLog I could see an error claiming that it could not load the exe.config.

This leads to the issue that my application cannot load any DLLs it ships along because file access is not allowed.

And important to know: if I start my application from a Kudo console it starts up fine.

Update: I added a bunch of additional checks to my application and it gets even more crazy. Some Source insights and log output can be found in this gist.

Update #2: I prepared an example project for everyone to try out. Just follow the steps from this Git Repo: https://github.com/Danielku15/AzureFileNotFound

My question

How can I ensure that my application can access the files it ships along? Is there a special deploy setting, or a web.config option which is important for the operations within Azure?

Upvotes: 0

Views: 1330

Answers (1)

Danielku15
Danielku15

Reputation: 1520

It seems the problem was in this case neither Azure, nor my code. It was the tools I used to deploy my app.

When I deploy my app through JetBrains Rider I face the mentioned issues, if I deploy it through Visual Studio 2022 the app starts up fine. I don't really understand yet the difference between these two but Rider is doing something terribly wrong.

I started to doubt Rider because even a fresh .net 5 application with standard settings did not run.

Hence, the problem is solved for me by using Visual Studio for deploying.

Upvotes: 1

Related Questions