Hi Alexandre,
I would recommend turning on Application Insights (Azure Monitor) to find out where the error is:
Diagnose exceptions in web apps with Application Insights
https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-exceptions
If you have this turned on you will be able to see what error is causing the 500 Gateway error through the Azure portal.
If this is helpful please accept answer.