ASP.NET Core Web API 不适用于 Azure

新西兰赛布

我对这个主题很陌生,但我已经使用 .Net 5 编写了一个 ASP.NET Core Web API。这个 API 只是读取和写入 Azure DB 的值。它在我的机器上运行良好,但在上传/发布到 Azure 后,我收到“500 - 内部服务器错误”

{ 
"statusCode": 500, 
"message": "Internal server error", 
"activityId": "15ed7068-cb40-4e79-8205-cc4c6d4be8be" 
}

我已经按照 Microsoft Doc 发布我的 API:https ://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-azure-api-management-using-vs?view = aspnetcore- 5.0

一旦我到了步骤https://docs.microsoft.com/en-us/aspnet/core/tutorials/publish-to-azure-api-management-using-vs?view=aspnetcore-5.0它就不起作用了。这是跟踪:

api-inspector (0.238 ms)
    {
    "request": {
        "method": "GET",
        "url": "http://xxx.azure-api.net/v1/Tests",
        "headers": [
            {
                "name": "sec-ch-ua",
                "value": "\"Chromium\";v=\"92\",\" Not A;Brand\";v=\"99\",\"Google Chrome\";v=\"92\""
            },
            {
                "name": "sec-ch-ua-mobile",
                "value": "?0"
            },
            {
                "name": "Ocp-Apim-Subscription-Key",
                "value": ""
            },
            {
                "name": "Sec-Fetch-Site",
                "value": "cross-site"
            },
            {
                "name": "Sec-Fetch-Mode",
                "value": "cors"
            },
            {
                "name": "Sec-Fetch-Dest",
                "value": "empty"
            },
            {
                "name": "X-Forwarded-For",
                "value": "xxx.xxx.xxx.xxx"
            },
            {
                "name": "Cache-Control",
                "value": "no-cache, no-store"
            },
            {
                "name": "Connection",
                "value": "Keep-Alive"
            },
            {
                "name": "Content-Type",
                "value": "text/plain;charset=UTF-8"
            },
            {
                "name": "Accept",
                "value": "*/*"
            },
            {
                "name": "Accept-Encoding",
                "value": "gzip,deflate,br"
            },
            {
                "name": "Accept-Language",
                "value": "en,de;q=0.9,en-US;q=0.8,it;q=0.7,it-IT;q=0.6,und;q=0.5"
            },
            {
                "name": "Host",
                "value": "xxx.azure-api.net"
            },
            {
                "name": "Referer",
                "value": "https://apimanagement.hosting.portal.azure.net/"
            }
        ]
    }
}
api-inspector (0.003 ms)
    {
    "configuration": {
        "api": {
            "from": "/v1",
            "to": {
                "scheme": "https",
                "host": "xxx.azurewebsites.net",
                "port": 80,
                "path": "/",
                "queryString": "",
                "query": {},
                "isDefaultPort": false
            },
            "version": null,
            "revision": "1"
        },
        "operation": {
            "method": "GET",
            "uriTemplate": "/Tests"
        },
        "user": "-",
        "product": "-"
    }
}
cors (0.020 ms)
    "Origin header was missing or empty and the request was classified as not cross-domain. CORS policy was not applied."
Backend
(25.737 ms)↑ Back to top
forward-request (0.093 ms)
    {
    "message": "Request is being forwarded to the backend service. Timeout set to 300 seconds",
    "request": {
        "method": "GET",
        "url": "https://xxx.azurewebsites.net:80/Tests",
        "headers": [
            {
                "name": "Host",
                "value": "xxx.azurewebsites.net:80"
            },
            {
                "name": "sec-ch-ua",
                "value": "\"Chromium\";v=\"92\",\" Not A;Brand\";v=\"99\",\"Google Chrome\";v=\"92\""
            },
            {
                "name": "sec-ch-ua-mobile",
                "value": "?0"
            },
            {
                "name": "Ocp-Apim-Subscription-Key",
                "value": ""
            },
            {
                "name": "Sec-Fetch-Site",
                "value": "cross-site"
            },
            {
                "name": "Sec-Fetch-Mode",
                "value": "cors"
            },
            {
                "name": "Sec-Fetch-Dest",
                "value": "empty"
            },
            {
                "name": "X-Forwarded-For",
                "value": "xxx.xxx.xxx.xxx,xxx.xxx.xxx.xxx"
            },
            {
                "name": "Cache-Control",
                "value": "no-cache, no-store"
            },
            {
                "name": "Content-Type",
                "value": "text/plain;charset=UTF-8"
            },
            {
                "name": "Accept",
                "value": "*/*"
            },
            {
                "name": "Accept-Encoding",
                "value": "gzip,deflate,br"
            },
            {
                "name": "Accept-Language",
                "value": "en,de;q=0.9,en-US;q=0.8,it;q=0.7,it-IT;q=0.6,und;q=0.5"
            },
            {
                "name": "Referer",
                "value": "https://apimanagement.hosting.portal.azure.net/"
            }
        ]
    }
}
forward-request (25.643 ms)
    {
    "messages": [
        "The underlying connection was closed: An unexpected error occurred on a send.",
        "Error occured while calling backend service.",
        "The handshake failed due to an unexpected packet format."
    ]
}

我已经尝试制作一个全新的项目并重新发布该项目,但没有成功。

willy40512

我有同样的问题,我通过将端口从 80 更改为 443(如果您使用 HTTPS)来解决它。希望它会帮助你。或者你可以参考这个https://github.com/ThreeMammals/Ocelot/issues/912

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Asp.net .core web api 版本控制不适用于 Url 路径段

调用SignalR Hub不适用于Asp.Net Core Web API

Postman JSON 不适用于 ASP.NET Core Web API

.Net Core Web API基本身份验证授权不适用于Azure

ASP.NET Core API 的 GET 请求中的可选参数不适用于 Swagger

我在 ASP.NET Core 2.2 Web API 中设置了 JWT 中间件。它仅适用于 RSA256 而不适用于 HS256

FromBody路由不适用于ASP.NET Core

.net Core API 不适用于 IIS

路由不适用于 asp.net api 项目

使用 Azure AD 保护 ASP.NET Core Web API

Web配置Windows授权。适用于部署,但不适用于本地。ASP.net

ASP.NET Core 3.1中的asp-action不适用于端点路由

依赖项注入不适用于具有Azure Key Vault Value asp.net core 3.0的RabitMQ Service Bus

.NET Core API 将不适用于 Azure 应用服务 - 您正在查找的资源已被删除、更名或暂时不可用

编辑并继续不适用于VS 2019(C#)的asp.net core 3.0

在asp.net core 2.1中产生不适用于xml的数据注释

Asp.net Core 2.0 Configure.Services <model>()绑定不适用于用户机密

ASP.NET Core CORS配置不适用于Firefox

ASP.NET Core Authorize属性不适用于JWT

更改默认操作不适用于ASP.NET Core 2

重定向到动作不适用于ASP.NET Core

ASP.NET Core appsettings.json reloadOnChange不适用于symlink文件吗?

HiddenInput 不适用于 ASP.NET Core 2.2 脚手架

Visual Studio 2017 Docker支持不适用于ASP.Net Core Angular或React项目

共享布局视图不适用于ASP.NET Core 2.1中的所有视图

ToList()不适用于Asp.Net Core动态生成的where子句

序列迁移不适用于 ASP.NET Core 2.1

Asp.Net Core 应用程序不适用于其他领域

asp.net core 2.1,Include()功能不适用于db first方式