My application has a .NET Core 7 backend and it uses a SQL database. I'm trying to deploy it onto an Azure App service (Windows platform) using the Azure CLI, but I have not had any luck so far.
I'm running across a strange problem. When I run the deploy command, the status is 4, and the message is successfully deployed. I checked the logs, and it says the deployment was successful, but the last deployment shows nothing, as can be seen in the screenshot below:
I have exhausted all my resources and can't figure out what's the problem. Here are all the operations that I'm performing along with the commands that I'm executing:
az group create --name QandAResourcesterminal --location EastUS
az appservice plan create --name qanda2021-backend-terminal --resource-group QandAResourcesterminal --sku S1 --location eastus --subscription Education
az sql server create --name qanda-server-terminal --resource-group QandAResourcesterminal --location eastus --admin-user qanda --admin-password Education@123
az sql db create --resource-group QandAResourcesterminal --server qanda-server-terminal --name qanda-db-terminal --service-objective S0
az sql server firewall-rule create --name AllowTraffic --server qanda-server-terminal --resource-group QandAResourcesterminal --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0
Then I got the connection string from Azure database, replaced {your_password}
with Education@123
in the connection string, and added it to application. i.e., backend/appsettings.json
file.
Then I executed the following commands:
az webapp create --name QandA2021-WebDeploy-terminal --resource-group QandAResourcesterminal --plan QandA2021-backend-terminal
zip -r backend.zip backend/*
az webapp config connection-string set --name QandA2021-WebDeploy-terminal --resource-group QandAResourcesterminal --settings DefaultConnection="Server={my connection string}" --connection-string-type SQLServer
az webapp deployment source config-zip --src backend.zip --name QandA2021-WebDeploy-terminal --resource-group QandAResourcesterminal
The deployment is successful as can be seen from this screenshot:
Then I navigate to Azure app service, click on default domain and I expect my webpage to open but I get the following page:
When I navigate to my_domain/api/question
, I expect a page containing the question details, but I get the following error:
From all the reading that I've done, I understand that it has something to do with my web.config file but it's right there:
Here's my web.config
file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\QandA.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
I've tried checking the file structure through Azure portal console, and here's my file structure:
The web.config
file is located in the wwwroot/backend/publish/
directory. Can someone help? Because I can't seem to understand what's really wrong.
The root cause of this issue is that the contents of the publish folder should be placed in the C:\home\site\wwwroot
folder of the azure app service.
You have two ways to fix the issue, one is modifying the azure-cli command and put the publish files under wwwroot.
The second way is you can change the Physical Path. Under this path, we should find QandA.dll
and web.config
files.