1

I'm pretty new to this subject, but I've written a ASP.NET Core Web API using .Net 5. This API just reads and writes values to a Azure DB. It works perfectly fine on my machine, but after the upload/publish to Azure I get an "500 - Internal Server error"

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

I've followed the Microsoft Doc for pubishing my API: https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-azure-api-management-using-vs?view=aspnetcore-5.0

Once I got to the step https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-azure-api-management-using-vs?view=aspnetcore-5.0 it doesn't work anymore. Here is the trace:

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."
    ]
}

I've already tried making a completely new project and republishing that one, without success.

SaibNZ
  • 13
  • 1
  • 2
  • Looks like the last few lines of that JSON describe the error happening. But it lacks details about where (such as a stack trace). Have you considered implementing proper exception logging in your application so you can get those details? – mason Aug 19 '21 at 13:20
  • Can you follow [the steps in this post](https://stackoverflow.com/questions/68779132/http-error-502-5-process-failure-after-deployed-the-net-core-to-azure-appserv/68813460#68813460), and update more error details in your question. – Jason Pan Aug 20 '21 at 01:45

1 Answers1

1

I have the same issue, I solved it by changing the port from 80 to 443(if u use HTTPS). Hope it will help u. Or u can reference this https://github.com/ThreeMammals/Ocelot/issues/912

willy40512
  • 26
  • 1