File not found for empty folder when using WEBSITE_RUN_FROM_PACKAGE
See original GitHub issueInvestigative 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
Think the line giving the error is the below one.
var files = Directory.GetFiles(functionAppDirectory, "*.deps.json", SearchOption.AllDirectories);
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
Hi @laurens1984, Thank you for your feedback! We will check for the possibilities internally and update you with the findings.
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