简体   繁体   English

Webhook 回调从 Azure Function 收到意外响应 301

[英]Webhook callback getting unexpected response 301 from Azure Function

I've created an Azure Function and hosted it in Azure.我创建了一个 Azure Function 并将其托管在 Azure 中。 It accepts "post" and "get" requests and I can run this locally and get some log output when I either GET or POST to it.它接受“post”和“get”请求,我可以在本地运行它,并在我 GET 或 POST 时获取一些日志 output。

When I host this in Azure, I can get the output the same if I do a GET or POST, which is what I expect (via postman).当我在 Azure 中托管它时,如果我执行 GET 或 POST,我可以获得相同的 output,这是我所期望的(通过邮递员)。

I'm using a third party tool for a callback to my Azure Function URL.我正在使用第三方工具来回调我的 Azure Function URL。 When this callback gets sent, I don't get any output in the Azure CLI for logs.发送此回调后,我在 Azure CLI 中没有收到任何 output 日志。 It is using the exact same address as I was using to get my output in the portal.它使用的地址与我在门户中获取 output 时使用的地址完全相同。

The third party tool is saying its getting an HTTP 301 response.第三方工具说它得到了HTTP 301响应。

Why would the callback be getting an HTTP 301 when I can post/get to the same address from Postman and get a 200 back?当我可以从 Postman 发布/获取相同地址并获得 200 时,为什么回调会获得 HTTP 301?

Function code: Function 代码:

[FunctionName("AddressNotification")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation($"Address Callback function hit from req: {req.Host.ToString()}");

            var content = await new StreamReader(req.Body).ReadToEndAsync();
            log.LogInformation($"Request body: {content}");

            return new OkResult();
        }

Third party tool saying I'm getting a 301:第三方工具说我收到了 301:

在此处输入图像描述

I would assume you have https only enabled in your function我假设您仅在 function 中启用了 https

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM