Search code examples
azureazure-front-door

Azure Frontdoor Dynamic Header


I'm using Azure Frontdoor and want to inspect the querystring for a key paid, and if it is present, use it in an Response Header.

For example, if the request comes in to https://example.com/?foo=bar, I'd like to return a header that uses this querystring value, ie: X-Foo-Header: bar

Is this possible?

I note I can access the {query_string} server variable in the Response Header action, but am unsure if Frontdoor has support to enable any type of dynamic inspection of that value. Ref: https://learn.microsoft.com/en-us/azure/frontdoor/rule-set-server-variables


Solution

  • If there is only one field in the query string and you know it ahead of time you can use the query_string server variable. You can use the offset to get only the value and return it in the predefined response header. This example rule set works for your example:

    implemented rule

    Query url string from a Chrome Incognito window:
    query string url

    Result in Chrome Developer Tools: enter image description here

    If you're wanting it to parse the query string field dynamically into an 'X-something-Header' I don't believe it's possible right now. You'd have to dynamically set the offset value and be able to parse the query string to determine the position of the '=' character.