4
votes

I 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 as part of a Team Foundation Server (TFS) 2017 build job, which is successful:

enter image description here

However, when trying a GET request such as the following URL:

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:

enter image description here

What am I missing?

2
You have to wait a few minutes until the deploy was finished. Are you using Docker?Alvaro Cantador
Well, you kinda need a web.config if you are going to host in IIS :)juunas
@AlvaroCantador - no docker yet, just a plain IIS (I think)tomab
@juunas I was suspecting that. What do I need to put in it?tomab

2 Answers

4
votes

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
votes

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