简体   繁体   English

Azure 函数:代理 + 部署槽 + 查询字符串参数

[英]Azure Functions: Proxy + Deployment Slot + Querystring parameter

I'm trying to implement a home-made "API gateway" for my Azure Functions using proxies to forward requests to different deployment slots depending on a query string parameter:我正在尝试为我的 Azure 函数实现一个自制的“API 网关”,使用代理根据查询字符串参数将请求转发到不同的部署槽:

myapi.azurewebsites.net/customer/123?organizationId=1 ----> myapi-prod.azurewebsites.net/customer/123?organizationId=1
myapi.azurewebsites.net/customer/123?organizationId=2 ----> myapi-test.azurewebsites.net/customer/123?organizationId=2

And so on and so forth.等等等等。

I've RTFM but I still can't figure out how to properly write the Route Templates to achieve this我有RTFM,但我仍然无法弄清楚如何正确编写路由模板来实现这一目标

Q : How can I configure function proxies for this scenario?:如何为这种情况配置功能代理?

Q2 : Is there a way to programatically declare these proxy configurations without writing a bunch of JSON, similar to [FunctionName] which allows me to declare my functions with a single attribute in my class? Q2 :有没有办法以编程方式声明这些代理配置,而无需编写一堆 JSON,类似于[FunctionName] ,它允许我在我的类中使用单个属性声明我的函数?

According to some test, azure function proxy doesn't support set the route template with query string like ?organizationId=1 .根据一些测试,azure 函数代理不支持使用?organizationId=1类的查询字符串设置路由模板。 The route template can just be set as customer/123/organizationId/1 .路由模板可以设置为customer/123/organizationId/1 So you can set the proxies as below:所以你可以设置代理如下:

Route template: customer/123/organizationId/1 --> Backend URL: myapi-prod.azurewebsites.net/customer/123?organizationId=1

Route template: customer/123/organizationId/2 --> Backend URL: myapi-test.azurewebsites.net/customer/123?organizationId=2

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

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