【问题标题】:Is it possible to pass through a backend url endpoint that is relative to that url through an Azure Function Proxy or perhaps api management是否可以通过 Azure 函数代理或 api 管理通过与该 url 相关的后端 url 端点
【发布时间】:2020-05-27 17:35:55
【问题描述】:

到目前为止,据我所知,使用 Azure 函数代理的唯一方法是重新路由现有 api,即直接调用该 api。例如:

后端网址

https://gateway-api.com/api/getSomething

路线模板

/api

代理网址

https://gateway.azurewebsites.net/api

我想要的是让后端 URL 通过相对于主端点的任何端点。

实际上是这样的:

后端网址

https://gateway-api.com/* 或者我什至尝试过这个https://gateway-api.com/{*restOfPath}

这样,任何跟随核心域 URL 的 api 仍将按预期工作。

这是对上面示例的重写:

后端网址 2

https://gateway-api.com/*

路线模板 2

/*

代理网址 2

https://gateway.azurewebsites.net/api/getSomething

当我这样做时,我无法让它工作,甚至无法到达调试器来记录任何内容。

这可能吗?如果不是,这是否是 Azure API 管理能够完成的事情?

【问题讨论】:

  • 您检查过 Azure 前门吗?

标签: azure azure-functions azure-api-management azure-function-app-proxy azure-functions-proxies


【解决方案1】:

你能提供你的配置文件吗?这是我的:

Proxies.json:

{
  "$schema": "http://json.schemastore.org/proxies",
  "proxies": {
    "proxy1": {
      "matchCondition": {
        "methods": [ "GET" ],
        "route": "/{test}"
      },
      "backendUri": "http://localhost:7071/abc/Function1"
    }
  }
}

host.json:

{
  "version": "2.0",
  "extensions": {
    "http": {
      "routePrefix": "abc"
    }
  },
  "logging": {
    "applicationInsights": {
      "samplingExcludedTypes": "Request",
      "samplingSettings": {
        "isEnabled": true
      }
    }
  }
}

这是我的函数的后端 url 和代理:

它们都可以正常工作。

如果您更改路由模板,我认为后端 url 不会有 /api,除非您将 /api 提供给 routePrefix。

无论如何,请出示有关如何配置代理和路由模板的文件。

【讨论】:

  • 我不明白。这不是我要问的。我知道如何使代理工作。这不是我的问题
  • @ChristianMatthew 你能解释一下this吗?我很抱歉误会。我不确定你是什么意思。你能解释一下吗?
  • 没关系,如果您重新阅读问题是如何将 url 转发到任何后端 url。基本上这就是我要问的
  • @ChristianMatthew 您的意思是通过代理 URL 访问您想访问的任何其他后端 URL?你是这个意思吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-23
  • 1970-01-01
  • 2023-03-10
  • 1970-01-01
  • 2010-09-12
  • 1970-01-01
相关资源
最近更新 更多