azure - .NET Core Web API 部署到 Azure 后无法工作

标签 azure .net-core azure-web-app-service asp.net-core-webapi

我有一个简单的 .NET Core Web API 应用程序 - 创建新项目时由 Visual Studio 创建的应用程序。我想通过 FTP 将其部署到 Azure 应用服务,作为 Team Foundation Server (TFS) 2017 构建作业的一部分,这是成功的:

enter image description here

但是,当尝试 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 中,我收到以下错误:

enter image description here

我错过了什么?

最佳答案

所以需要一个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/

相关文章:

c# - .NET Core 中的环境变量配置

c# - 自增非键值 Entity Framework 核心2.0

c# - 如何读取 Azure 网站应用程序设置值

azure - 如何完全删除 azure 网站

azure - 无法使用系统分配的托管标识 ID 登录 Azure

node.js - 使用 Azure 存储 Node SDK 创建队列消息时,队列触发的 Azure 函数抛出异常

azure - 使用 Microsoft.ApplicationServer.Caching.DataCacheFactory 时 EF4.1 挂起 120 秒

azure - HashiCorp Vault 自动使用 Azure Vault 解封 - 仍然显示 - 恢复密封类型为 shamir

asp.net - 在 Azure 网站上使用 Azure 缓存服务(预览版)时出现问题

c# - 如何使用 AWS lambda 处理大型 zip 文件?