1

Am learning how to use Azure functions and so new to it. I have a httptrigger Azure function written in NodeJs. I am thinking of a logic on how to parse data from httptrigger function URL and use it in my code. Would like some suggestions on this?

In simple words,

  1. I would like to know how to pass a string parameter to the functions URL.
  2. Then parse the string from the URL and use it in my code logic.
Janusz Nowak
  • 2,595
  • 1
  • 17
  • 36
Ross
  • 99
  • 2
  • 12

2 Answers2

5

See an example in Customize the HTTP endpoint.

You can define route in function.json:

"route": "products/{category:alpha}/{id:int?}"

and then get URL parts from context:

var category = context.bindingData.category;
var id = context.bindingData.id;
Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
2

Mikhail's answer works if you want to put the "parameters" in the base part of the URL separated by /. However, if you wanted to use query parameter syntax (e.g. http://myEndpoint?myParam1=10&myParam2=hello), those show up already parsed in context.req.query

Larry Maccherone
  • 9,393
  • 3
  • 27
  • 43