我有一个简单的 .NET Core Web API 应用程序 - 创建新项目时由 Visual Studio 创建的应用程序。我想通过 FTP 将其部署到 Azure 应用服务,作为 Team Foundation Server (TFS) 2017 构建作业的一部分,这是成功的:
但是,当尝试 GET
请求(例如以下 URL)时:
http://somerandomname.azurewebsites.net/api/values
我得到的只是一个带有文本的 404:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
从 Kudu 中,我收到以下错误:
我错过了什么?
最佳答案
所以需要一个web.config。当添加新项目时 VS 2017 会填充一些默认值,这并不好。使用 VS 2017 Web api 默认项目,我使用右键菜单发布了它。这工作顺利。我从 Azure Web 服务获取了 web.config 并将其集成到我自己的项目中,仅更改了 dll 名称。现在,当构建作业代表 TFS 运行时,它会将 web.config 包含在通过 FTP 上传到 Azure 应用服务的文件中。
这是我结束的 web.config:
<?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>
关于azure - .NET Core Web API 部署到 Azure 后无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51558155/