dotnet / dotnet/aspnetcore

ASP.NET Core Logging Azure Site Extension causes 500.30 ANCM Startup Error

Open
#49,265 0 comments 0 reactions 0 assignees View on GitHub
area-networking
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 10h
Merged PRs (30d)
281

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Describe the bug

After re-publishing a site to an Azure App Service **without making code changes**, this error was thrown and caused the site to go down with a 500.30 ANCM startup error:

```
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
```

Our project depends on Serilog.AspNetCore which depends on `Microsoft.Extensions.Logging.Abstractions`.

The project is targeting .Net 7: `net7.0` and the app service is configured in Azure to use .Net 7:
![image](https://github.com/dotnet/aspnetcore/assets/13984239/6c502151-2007-4dd3-9933-f8af868450e2)

Removing the ASP.NET Core Site Extension fixed the issue without republishing the application.

Looking at the source code of [Logging.AzureAppServices](https://github.com/dotnet/aspnetcore/blob/main/src/Logging.AzureAppServices/src/Microsoft.Extensions.Logging.AzureAppServices.csproj) I do see that it includes `` as well.

### Expected Behavior

Republishing a site without changing any code should not cause the site to go down due to the automatically installed ASP.NET Core Logging site extension

### Steps To Reproduce

N/a

### Exceptions (if any)

```
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.Extensions.Logging.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
```

### .NET Version

7.0.203

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.