Your documentation provices this guideance for publsihing to Azure App Service:
Our AspNetZero app is a multi-tenant app that uses a custom domain name.
This is what we use and it works when publishing to our internal IIS staging server using ASPNETCORE_ENVIRONMENT = Staging:
<span class="colour" style="color: rgb(46, 117, 182);">"App"<span class="colour" style="color: rgb(0, 0, 0);">: {</span></span> <span class="colour" style="color: rgb(163, 21, 21);"><span class="colour" style="color: rgb(0, 0, 0);"> </span><span class="colour" style="color: rgb(46, 117, 182);">"WebSiteRootAddress"</span><span class="colour" style="color: rgb(0, 0, 0);">:</span> "https://{TENANCY_NAME}.internaldomainname.com"</span> }
This is what we are trying to use when publishing to an Azure App Service that has ASPNETCORE_ENVIRONMENT = Production:
<span class="colour" style="color: rgb(46, 117, 182);">"App"<span class="colour" style="color: rgb(0, 0, 0);">: {</span></span> <span class="colour" style="color: rgb(163, 21, 21);"><span class="colour" style="color: rgb(0, 0, 0);"> </span><span class="colour" style="color: rgb(46, 117, 182);">"WebSiteRootAddress"</span><span class="colour" style="color: rgb(0, 0, 0);">:</span> "https://{TENANCY_NAME}.premierpointonline.com"</span> }
The application never works on Azure - we just get 500 Internal Server Error with no other details:
What do we need in the appsettings.production.com to get this to work in Azure App Service?
6 Answer(s)
-
0
They're going to ask Which product? and then probably tell you to check the log - which should be located at \App_Data\Logs\Logs.txt
The issue you might run into trying to find that file is if you're using an App service you need to find a way to FTP to the location in order to reach the log file blob and download it locally
Heres the angular content which might help you figure out what to add there https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Overview-Angular#basic-configuration
-
0
Thanks for pointing out that I did not specify my version.
Here it is:
AspNetZero 7.2.0 - Asp.Net Core MVC & jQuery AspNetCore 2.2.0 Targeting .Net Framework 4.6.1
-
0
hi @dev1_premierpoint
we just get 500 Internal Server Error with no other details:
Please check your application's logs as @smry said. \App_Data\Logs\Logs.txt
-
0
Once I learned a little bit about AspNetZero's approach to logging and found the log file, it turned out that the problem was that the Azure Service App could not connect to the Azure Sql Database.
The reason for that was that your documentation page about publishing to Azure App Service (https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Deployment-Mvc-Core-Azure) does not really address how the Azure App Service and the Azure Sql Database need to be configured to communicate.
It turns out that there are lots of different options for getting an Azure App Service to talk to an Azure Sql Database and the level of security goes from poor to good depending on which option you choose to set up.
I chose one of the "good" security options, but its more complicated to configure and I didn't quite get it right. So, that turned out be be my problem.
FYI, the "easy", but "poor security" option is to enable this setting in your Azure Sql Server:
The reason this option offer poor security is that when you turn it on, all of Azure (ie. every Azure customer in the Region) can access the SQL Server through its firewall. Of course, they need a good user name and password to login, but still its a bad practice to leave your SQL Server open to this.
The more difficult to set up, but good approach to security is to set up a Vnet for the Azure App Service and Azure SQL Server to use for private communication. I've got that working now in my deployment.
-
0
Also, for the record, there was nothing wrong with my appsettings.production.json configuration. It is correct as it is shown above. This all had to do with the Sql Connection problem.
Also, one thing I did that may or may not have been required is to add ASPNETCORE_ENVIRONMENT = Production as a envrionment variable to my Azure App Service using the Azure Portal.
-
0
I've found a number of issues come up if you are not running ASPNETCORE_ENVIRONMENT = Production when hosting
One of which being the Emails will NOT get sent if in Development, theres code that catches email credentials and fakes sending it