简体   繁体   English

嵌套路由Azure Function返回404未找到

[英]Nested route in Azure Function returns 404 not found

I have multiple functions handling GET, PUT & POST API's with different paths in my Azure Function and they all work fine.在我的 Azure Function 中,我有多个处理 GET、PUT 和 POST API 的函数,它们都工作正常。 Each function has one index.js file handling one HttpMethod only & I have a routePrefix of "api" in the hosts.json.每个 function 都有一个 index.js 文件只处理一个 HttpMethod & 我在 hosts.json 中有一个“api”的路由前缀。 The function.json for one of the functions can be found below其中一个功能的 function.json 可以在下面找到

{
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "route": "bike/{id}/like",
      "methods": [
        "put"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ]
}

The problem I am facing is the two PUT requests below don't work & I get a 404 not found.我面临的问题是下面的两个 PUT 请求不起作用,我收到 404 not found。 However this seems to work when I run the function locally in vscode & check using Postman.但是,当我在 vscode 中本地运行 function 并使用 Postman 检查时,这似乎有效。

http://<MyAzureFuncName>.azurewebsites.net/api/bike/63d51c0bb593aec8734638e5/like

http://<MyAzureFuncName>.azurewebsites.net/api/bike/63d51c0bb593aec8734638e5/dislike

UPDATE 1 I have just found out that calling the above API's using the test/run feature on the Azure function in the portal works but not when I try using Postman. Any ideas why this is the case更新 1我刚刚发现使用门户中 Azure function 上的测试/运行功能调用上述 API 有效,但当我尝试使用 Postman 时无效。任何想法为什么会这样

I also have GET & an update method for PUT following a similar signature (shown below) which both work locally but on Azure the PUT is returning the GET result when checking with Postman. Could this PUT overload be the cause for the mix up.我也有 GET 和 PUT 的更新方法,遵循类似的签名(如下所示),两者都在本地工作,但在 Azure 上,PUT 在检查 Postman 时返回 GET 结果。这个 PUT 过载是否是混淆的原因。

http://<MyAzureFuncName>.azurewebsites.net/api/bike/63d51c0bb593aec8734638e5

UPDATE 2更新 2

I have found that all the above PUT requests work if I use https instead of http. The other POST, DELETE & GET requests work with both.我发现如果我使用 https 而不是 http,上述所有 PUT 请求都有效。其他 POST、DELETE 和 GET 请求都适用。 This is all the more baffling, can anyone shed some light on this.这更令人费解,任何人都可以对此有所了解。

I would appreciate any help & guidance in spotting the obvious.如果您能提供帮助和指导,我将不胜感激。

Thanks谢谢

Since you are able to reach the endpoint with https and not with http, I assume that the error is the HTTP Only setting.由于您可以使用 https 而不是 http 到达端点,因此我假设错误是HTTP Only设置。

Navigate to your Function App, and go to TLS/SSL settings (classic) in the Settings section and switch HTTPS Only to Off .导航到您的 Function 应用程序,go 到设置部分中的TLS/SSL 设置(经典) ,然后将HTTPS Only切换到Off


When it comes to this section:说到这一部分:

I also have GET & an update method for PUT following a similar signature (shown below) which both work locally but on Azure the PUT is returning the GET result when checking with Postman. Could this PUT overload be the cause for the mix up.我也有 GET 和 PUT 的更新方法,遵循类似的签名(如下所示),两者都在本地工作,但在 Azure 上,PUT 在检查 Postman 时返回 GET 结果。这个 PUT 过载是否是混淆的原因。

I would say it's normal to return the resource when making a PUT request.我会说在发出 PUT 请求时返回资源是正常的。 For example, if you update the resource, you would then return the data with the updated information.例如,如果您更新资源,您将返回包含更新信息的数据。

Hope it helps.希望能帮助到你。

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

相关问题 新部署azure function返回404 Not Found错误 - New deployed azure function returns 404 Not Found error React Route:刷新已部署的应用程序后找不到 404 - React Route: 404 Not Found after refreshing the deployed application 任何 AWS EB Laravel 路由获取 404 Not Found nginx/1.16.1 - Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1 来自 PUT 的 Azure Blob 存储文档中的“404 Resource Not Found” - "404 Resource Not Found" From Azure Blob Storage Document from PUT 从Azure数据工厂调用Azure Function报404错误 - Calling Azure Function from Azure Data Factory Gives 404 Error 找不到模块 python Azure function - module not found python Azure function Spring Boot 3 升级 - Tomcat HTTP 状态 404 - 在 Azure 上找不到 - Spring Boot 3 upgrade - Tomcat HTTP Status 404 - Not Found on Azure 在 Asp.net web 应用程序部署在 azure 应用程序服务中,获取服务(.svc)端点的 404 未找到错误 - Getting 404 not found error for service(.svc) endpoints in Asp.net web application deployed on azure app service 将新端点添加到 Azure App Service 插槽上的 my.net6 API 时,我收到 404 not found ONLY on the new endpoints - When adding new endpoints to my net6 API on Azure App Service slot, I receive 404 not found ONLY on the new endpoints Azure API 管理层回应 404 - Azure API Management responses 404
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM