问题
I do have a simple .Net Core web api application, the one made by Visual Studio when a new project is created. I want to deploy it to an Azure App Service via FTP (part of a TFS 2017 build job), which is successful:
However, when trying a GET like http://somerandomname.azurewebsites.net/api/values
all I get is a 404 with the text
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
From Kudu I get the following error:
What am I missing?
回答1:
So a web.config is needed. The one which VS 2017 populates with some default values when a new item is added it's not good. Using a VS 2017 web api default project, I've published it using right-click menu. That worked seamlessly. I've took the web.config from Azure web service and integrated it in my own project, changing only the dll name. Now, when a build job is running on behalf of TFS, it has the web.config among the files which are uploaded via FTP to Azure app service.
Here is the web.config I've ended with:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore"/>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Somerandomname.WebApi.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
回答2:
I had a similar problem using Azure DevOps.
I decided to try publishing by right click deploy to a different app service, so that I could see what web.config I should have.
The right click deployed app did show /api/values where as the devops app did not.
The only difference in the web.configs were the location of stdoutLogFile
Using right click deploy
stdoutLogFile="\\?\%home%\LogFiles\stdout"
Using devops
stdoutLogFile=".\logs\stdout
However right click deploy had included all my 3rd party dlls, so I am thinking somehow my devops pipeline nuget settings need correcting.
I am asking about that here
来源:https://stackoverflow.com/questions/51558155/net-core-web-api-not-working-after-deployed-to-azure