Not saying this is gold but, maybe something to think about when getting 500.30 in Azure App Service after publishing .net 8:
Build with Target OS Windows
Publish with Target Runtime: win-x64
Yet for a Function App:
Build with Target OS (none)
Publish with Target Runtime: Portable