question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

File not found for empty folder when using WEBSITE_RUN_FROM_PACKAGE

See original GitHub issue

Investigative information

  • Timestamp: 2021-11-26T13:11:58.9505949Z
  • Function App version: v4
  • Function name(s) (as appropriate): Functions.RenderSwaggerDocument
  • Invocation ID: 9b9ac677-d60b-446d-8623-228acef8f606
  • Region: West Europe

Repro steps

The Function App gets build with ‘dotnet publish’, in the resulting file structure there is a folder that is empty named ‘nl’. The file structure gets zipped. We publish the zip file to Azure with Azure DevOps, but publishing from Visual Studio 2022 gives the same result. Our Azure Functions instance is configured with WEBSITE_RUN_FROM_PACKAGE with value 1.

Our Functions App uses Microsoft.Azure.WebJobs.Extensions.OpenApi version 1.0.0. We call the endpoint to render the Swagger UI and get the following stacktrace:

could not find file 'D:\home\site\wwwroot\nl'.

   at System.IO.Enumeration.FileSystemEnumerator`1.FindNextEntry()
   at System.IO.Enumeration.FileSystemEnumerator`1.DirectoryFinished()
   at System.IO.Enumeration.FileSystemEnumerator`1.FindNextEntry()
   at System.IO.Enumeration.FileSystemEnumerator`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiHttpTriggerContext.GetRuntimeFilenameAsync(String functionAppDirectory)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiHttpTriggerContext.SetApplicationAssemblyAsync(String functionAppDirectory, Boolean appendBin)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.Core.Extensions.OpenApiHttpTriggerContextExtensions.AuthorizeAsync(Task`1 context, IHttpRequestDataObject req)
   at Microsoft.Azure.WebJobs.Extensions.OpenApi.OpenApiTriggerFunctionProvider.RenderSwaggerUI(HttpRequest req, ExecutionContext ctx, ILogger log)

When I open the Kudu site for the Azure Functions instance and open CMD and go to the folder ‘D:\home\site\wwwroot\nl’ and use ‘dir’ I get the output:

 Volume in drive D is Windows
File Not Found
 Volume Serial Number is B492-AC54

 Directory of D:\home\site\wwwroot\nl

This makes me think the issue is not with Microsoft.Azure.WebJobs.Extensions.OpenApi.

Expected behavior

That empty folders are readable.

Actual behavior

The empty folder is not found.

Known workarounds

Remove all empty folder before publishing to Azure Functions.

Related information

Source Microsoft.Azure.WebJobs.Extensions.OpenApi

azure-functions-openapi-extension/src/Microsoft.Azure.WebJobs.Extensions.OpenApi/OpenApiHttpTriggerContext.cs

Think the line giving the error is the below one.

var files = Directory.GetFiles(functionAppDirectory, "*.deps.json", SearchOption.AllDirectories);

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
v-bbalaiagarcommented, Nov 30, 2021

Hi @laurens1984, Thank you for your feedback! We will check for the possibilities internally and update you with the findings.

1reaction
sammeidroidcommented, Jan 7, 2022

Had a similar problem with deployment via Azure pipeline. In the deployment task “AzureFunctionApp@1” I change the “deploymentMethod” from ‘runFromPackage’ to ‘zipDeploy’. After that it worked.

See here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment?view=azure-devops#zip-deploy

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run your functions from a package file in Azure
With the WEBSITE_RUN_FROM_PACKAGE app setting value of 1 , the zip deployment APIs copy your package to the d:\home\data\SitePackages (Windows) ...
Read more >
How to make function app run as read and write mode
Basically I have to create a empty directory in bin but I am getting error as my function app is running in read...
Read more >
Why isn't Azure App Service Deploy copying files to my ...
I was recently working with a collegue to deploy a Sitecore app to Azure via Pipelines. The release was running successfully, ...
Read more >
Invalid Access to memory location in KUDU App Services
To resolve this problem I set WEBSITE_RUN_FROM_PACKAGE = 0 in the Configuration section of the Azure App Services followed by a service restart....
Read more >
Deploy Web and Function Apps with Run from Package
The way "Run from Package" works is that you simply set up a special App Setting called WEBSITE_RUN_FROM_PACKAGE and its value tells App...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found