Fede
Fede

Reputation: 44038

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:

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

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?

Upvotes: 0

Views: 236

Answers (1)

Hury Shen
Hury Shen

Reputation: 15734

According to some test, azure function proxy doesn't support set the route template with query string like ?organizationId=1. The route template can just be set as 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

Upvotes: 1

Related Questions