到目前为止,从我的角度来看,使用Azure Function代理的唯一方法是重新路由现有api,直接调用该api。例如:
后端URL
https://gateway-api.com/api/getSomething
路由模板
/api
代理URL
https://gateway.azurewebsites.net/api
我想要让后端URL相对于主端点传递任何端点。
有效地是:
后端URL
[https://gateway-api.com/*
或我甚至尝试过此https://gateway-api.com/{*restOfPath}
这样,遵循核心域URL的所有api仍将按预期工作。
这里是上面示例的重写:
后端URL 2
https://gateway-api.com/*
路由模板2
/*
代理URL 2
https://gateway.azurewebsites.net/api/getSomething
当我这样做时,我无法使其正常工作,甚至无法到达调试器以记录任何内容。
这是否可能,如果不是,这将是Azure API Management能够完成的事情?
您可以提供您的配置文件吗?这是我的:
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和代理:
它们两个都工作正常。
如果更改路由模板,除非您将/api
赋予routePrefix,否则我认为后端URL将没有/api
。
无论如何,请显示有关如何配置代理和路由模板的文件。