Using http header value in azure function binding

Viewed 273

I am trying to read the api_key from the headers and pass it as binding expression, as show below:

{
      "type": "table",
      "direction": "in",
      "name": "subscriptions",
      "tableName": "subscriptions",
      "partitionKey": "{api_key}",
      "take": "50",
      "connection": "learnbindingslab1_STORAGE"
 }

what would the correct expression to get the api_key from the request headers?

1 Answers

It seems you can use any value under context.bindingData, and you can access nested data with dot notation - so in this case given:

context.bindingData =

{
  "headers": {
    "some-header": "value"
  }
}

You can use it as a binding expression in Id/PartitionKey/sqlQuery with {headers.some-header}.


{
  "Id": "{headers.some-id}",
  "PartitionKey": "{headers.some-key}",
  "sqlQuery": "SELECT * FROM O WHERE O.key = {headers.some-value}"
}
Related