Closed saithis closed 2 years ago
We encounter the exact same error for one of our solutions. When deploying from VS2019, the application starts without a problem, but when deployed through an Azure Pipelines Release pipeline, the application fails to start with the error message shown above. The release task defaults to "run from package". The Azure Web App uses a windows host. We also used Kudu to verify that the directory exists and even accessed D:\home\site\diagnostics from our code successfully (as long as we did not include the code to configure logging with AddAzureWebAppDiagnostics). Unfortunately, we were unable to reproduce the behavior for a smaller solution. For now, we were able to solve the problem by setting the deployment method to "WebDeploy" in the Azure Release pipeline.
I did some further testing and it seems like the diagnostics folder is the problem.
I used this code:
var dirPath = "D:\\home\\site\\diagnostics";
var filePath = $"{dirPath}\\settings.json";
Log.Error($"Directory.Exists: {Directory.Exists(dirPath)}");
Log.Error($"File.Exists: {File.Exists(filePath)}");
logpathfiles("D:\\home\\site");
logpathfiles("D:\\home\\site\\diagnostics");
void logpathfiles(string path)
{
try
{
Log.Error($"Path: {path}");
Log.Error($"Directory.GetDirectories: {string.Join(",", Directory.GetDirectories(path))}");
Log.Error($"Directory.GetFiles: {string.Join(",", Directory.GetFiles(path))}");
}
catch (Exception e)
{
Log.Error(e, "logpathfiles failed");
}
}
and got this result:
[ERR] Directory.Exists: True
[ERR] File.Exists: False
[ERR] Path: D:\home\site
[ERR] Directory.GetDirectories: D:\home\site\deployments,D:\home\site\diagnostics,D:\home\site\locks,D:\home\site\logs,D:\home\site\wwwroot
[ERR] Directory.GetFiles:
[ERR] Path: D:\home\site\diagnostics
[ERR] logpathfiles failed
System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\home\site\diagnostics'.
at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String path, Boolean ignoreNotFound)
at System.IO.Enumeration.FileSystemEnumerator`1.Init()
at System.IO.Enumeration.FileSystemEnumerator`1..ctor(String directory, Boolean isNormalized, EnumerationOptions options)
at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String directory, FindTransform transform, EnumerationOptions options, Boolean isNormalized)
at System.IO.Enumeration.FileSystemEnumerableFactory.UserDirectories(String directory, String expression, EnumerationOptions options)
at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
at System.IO.Directory.GetDirectories(String path)
at (omitted).Program.<Main>g__logpathfiles|2_0(String path) in C:\(omitted)\Program.cs:line 98
Somehow the diagnostics folder is there, but not accessible from code. If I try to open the folder and settings.json from kudu, it works.
@suwatch Is there anything odd about the D:\home\site\diagnostics
directory that would cause failures when trying to path traverse it in .NET?
Tagging subscribers to this area: @eerhardt, @maryamariyan See info in area-owners.md if you want to be subscribed.
Author: | saithis |
---|---|
Assignees: | - |
Labels: | `area-Extensions-Hosting`, `untriaged` |
Milestone: | - |
Hi What is the solution this?
We are also facing the same issue in Azure App Service. Dotnet 5 is being used.
We are also experiencing the same exact error as described.
The only solution for us was to change (in web.config) AspNetCoreModuleV2 to AspNetCoreModule.
We don't think this is a good solution, since (I believe) it takes us out of process, although it works.
Please advise.
Unfortunately we never found a solution and stopped using azure web app diagnostics.
Unfortunately we never found a solution and stopped using azure web app diagnostics.
Then how are you analyzing the app logs? Diagnostics is for debugging of app right?
We use Serilog to log to a different place now.
Edit: For us the amount of apps increased to such an amount, that a single sink for all logs of all apps was the way to go anyway. But if you only have one or a few apps, then this is much more cumbersome and a fix to this bug would probably be preferable to you.
Since the AzureAppServicesLoggerFactoryExtensions.AddAzureWebAppDiagnostics
code is in dotnet/aspnetcore
, I am transferring this issue to that repo.
I've tried to repro the issue and been unsuccessful so far. New Azure App Service, turn on diagnostics, zip deploy app that uses AzureWebAppDiagnostics, see that app is running and logs are streaming through portal.
Is there some specific steps to hit the issue or is it random?
Probably was already stated, but it only occurred for me with net5 projects
Thanks for contacting us.
We're moving this issue to the Next sprint planning
milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
Can anyone confirm whether this issue is still occurring? There was a recent App Service update that fixed a file system issue that this sounds very similar to.
No response on this issue, so I'll close it. If anyone hits it we can reopen.
Describe the bug
AddAzureWebAppDiagnostics throws an exception if used in combination with azure webapp zip deploy. There is no exception if we deploy the code with Visual Studio (no zip deploy).
To Reproduce
Steps to reproduce the behavior:
Run this code:
Expected behavior
It should find and be able to read the D:\home\site\diagnostics\settings.json, as it is definitelly there.
Additional context
We use AspNetCoreModuleV2 with InProcess hosting and .NET Core 3.0