I created sample Asp. net core 3.1 application and deployed to the Azure Web App service.
It Good to update your app .net 3.1 version to .net 8 as @LexLi suggested.
If you want to continue with .net 3.1 version deploy your app to Azure Web app service through Visual Studio.
I selected my project -> Right Click -> Publish -> Azure -> Azure App service (Windows) -> Create new.




After Create new I filled the necessary details and clicked the Create button.

I selected the newly created web app and clicked Finish button.

It is successfully published to Azure as shown below.

You can check Runtime Stack - Dotnetcore in Overview page of Azure Web app.

Azure Web App Output:
