【发布时间】:2021-10-07 17:25:55
【问题描述】:
我遇到的问题似乎与 this one 相同,但解决方案不起作用 - proxies.json 曾经并且设置为“始终复制”。
我有带有 Azure Functions v2 和 docker 容器的 .net 核心 API,我想向其代理一些请求。部署后一切正常,但本地代理返回 404 响应。
proxies.json:
{
"$schema": "http://json.schemastore.org/proxies",
"proxies": {
"review": {
"debug": true,
"matchCondition": {
"route": "api/{docId}/proxy/review/{*restOfPath}"
},
"backendUri": "https://my-docker-container.azurewebsites.net/{restOfPath}",
"requestOverrides": {
"backend.request.headers.Some-Header": "request.headers.Cookie"
}
}
}
}
本地 docker 容器正在侦听端口 3000,因此我将 backendUri 替换为 http://localhost:3000/{restOfPath},但它返回 404。Docker 端点永远不会被命中。我可以通过从 Postman 调用预期的 URL 来确认 docker 容器正在运行和工作。
除了解决方案之外,还有什么方法可以尝试更多地调试它吗?无法从日志中获取任何有用的信息。
使用已部署资源时的成功日志:
[2021-08-02 10:01:06] Executing HTTP request: {
[2021-08-02 10:01:06] "requestId": "8c60239b-046d-464b-8a3a-09e0f5c55090",
[2021-08-02 10:01:06] "method": "POST",
[2021-08-02 10:01:06] "uri": "/api/4708a861-d8b2-4033-a1da-1a07afca4161/proxy/review/api/review"
[2021-08-02 10:01:06] }
[2021-08-02 10:01:06] Function started (Id=ebfbabc0-1a5b-4129-9280-14ae322e23ba)
[2021-08-02 10:01:06] Executing 'Functions.review' (Reason='This function was programmatically called via the host APIs.', Id=ebfbabc0-1a5b-4129-9280-14ae322e23ba)
[2021-08-02 10:01:06] Executing request via Azure Function Proxies
[2021-08-02 10:01:22] Function completed (Success, Id=ebfbabc0-1a5b-4129-9280-14ae322e23ba, Duration=16363ms)
[2021-08-02 10:01:22] Executed 'Functions.review' (Succeeded, Id=ebfbabc0-1a5b-4129-9280-14ae322e23ba)
[2021-08-02 10:01:22] Executed HTTP request: {
[2021-08-02 10:01:22] "requestId": "8c60239b-046d-464b-8a3a-09e0f5c55090",
[2021-08-02 10:01:22] "method": "POST",
[2021-08-02 10:01:22] "uri": "/api/4708a861-d8b2-4033-a1da-1a07afca4161/proxy/review/api/review",
[2021-08-02 10:01:22] "authorizationLevel": "Anonymous",
[2021-08-02 10:01:22] "status": "OK"
[2021-08-02 10:01:22] }
使用本地资源不成功的日志:
[2021-08-02 07:58:02] Executing HTTP request: {
[2021-08-02 07:58:02] "requestId": "f562eae9-b2c7-4ef8-84ba-83d42f59c4b7",
[2021-08-02 07:58:02] "method": "POST",
[2021-08-02 07:58:02] "uri": "/api/4708a861-d8b2-4033-a1da-1a07afca4161/proxy/review/api/review"
[2021-08-02 07:58:02] }
[2021-08-02 07:58:02] Function started (Id=28149473-125c-4fc4-958d-348604559e10)
[2021-08-02 07:58:02] Executing 'Functions.review' (Reason='This function was programmatically called via the host APIs.', Id=28149473-125c-4fc4-958d-348604559e10)
[2021-08-02 07:58:02] Executing request via Azure Function Proxies
[2021-08-02 07:58:02] Function completed (Success, Id=28149473-125c-4fc4-958d-348604559e10, Duration=169ms)
[2021-08-02 07:58:02] Executed 'Functions.review' (Succeeded, Id=28149473-125c-4fc4-958d-348604559e10)
[2021-08-02 07:58:02] Executed HTTP request: {
[2021-08-02 07:58:02] "requestId": "f562eae9-b2c7-4ef8-84ba-83d42f59c4b7",
[2021-08-02 07:58:02] "method": "POST",
[2021-08-02 07:58:02] "uri": "/api/4708a861-d8b2-4033-a1da-1a07afca4161/proxy/review/api/review",
[2021-08-02 07:58:02] "authorizationLevel": "Anonymous",
[2021-08-02 07:58:02] "status": "NotFound"
[2021-08-02 07:58:02] }
更新: 如果有任何疑问可能与 Docker 有关,则可以将其划掉。创建了新的虚拟 API,这是同样的问题。
【问题讨论】:
标签: azure proxy azure-functions