Resolving HTTP 404 Errors in Azure Function App After Migrating from .NET 6 to .NET 8

Senthil G

published September 27, 2024, 04:59:51 PM UTC

0
0
0
0
Resolving HTTP 404 Errors in Azure Function App After Migrating from .NET 6 to .NET 8
3 min read

Recently, while working on a migration for an Azure Function App from .NET 6 to .NET 8, we encountered a frustrating issue that resulted in multiple HTTP 404 errors, as highlighted in the above image. Initially, the migration process seemed successful, and everything was functioning correctly. However, after some time, our application began throwing 404 Not Found errors, impacting over 1,000 requests in a 24-hour period.

The Problem

Upon further investigation, we discovered that the issue wasn't with the code itself, but rather with the Azure Function App's runtime environment. For unknown reasons, the version of the framework had reverted back to .NET Framework 4.0 from the newly migrated .NET 8 (Isolated Version). This version mismatch caused our function app to be incompatible with the existing codebase, resulting in the 404 errors, as the system could no longer locate the required resources.

Troubleshooting

To diagnose the issue, we spent significant time analyzing the logs in both API Management (APIM) and Azure Function logs. Initially, the focus was on potential misconfigurations in routing, API endpoints, or application settings. However, after ruling these out, we started looking deeper into the platform and runtime settings.

The Root Cause

Eventually, we identified that the root cause of the 404 errors was the unintentional downgrade of the runtime environment back to .NET 4.0. The switch from .NET 8 to an older version led to the Azure Function App failing to serve the correct resources, which caused the frontend to throw 404 errors.

The Fix

To resolve this, we changed the runtime environment back to .NET 8 (Isolated Version). After updating the version in Azure App Service, the Azure Function App returned to normal, and all endpoints worked as expected without any further issues.

Lessons Learned

  1. Monitor Platform Settings Post-Migration: Even if everything seems fine after migrating to a newer framework, it’s essential to keep an eye on runtime settings in the hosting environment, such as Azure App Service, to ensure they do not revert to older versions.
  2. Log Analysis is Key: When dealing with platform-related issues like these, thorough log analysis of APIM and Azure Function logs can provide invaluable insight into what is happening behind the scenes.
  3. Framework Compatibility: Always ensure that the correct framework version is specified and maintained throughout the application's lifecycle to avoid runtime errors.

Conclusion

After reverting the environment back to .NET 8 (Isolated Version), the Azure Function App worked as expected without further HTTP 404 errors. Moving forward, we have implemented additional monitoring to alert us if there are any unexpected changes to the runtime environment.

Comments