-
Notifications
You must be signed in to change notification settings - Fork 457
Http Functions
By default, when you create an HTTP triggered or WebHook function the function is addressable via a route of the form http://<yourapp>.azurewebsites.net/api/<funcname>
. You can customize this route via the route
property in your function.json
file, e.g.:
{
"bindings": [
{
"type": "httpTrigger",
"name": "req",
"direction": "in",
"methods": [ "get" ],
"route": "products/{category:alpha}/{id:int?}"
},
{
"type": "http",
"name": "res",
"direction": "out"
}
]
}
This function will be addressable via url http://<yourapp>.azurewebsites.net/api/products/electronics/123
. This route also demonstrates support for route constraints. Documentation on the constraint formats supported can be found here.
In a C# function, you can then define parameters that bind to the route parameters like so:
public static Task<HttpResponseMessage> Run(
HttpRequestMessage request, string category, int? id, TraceWriter log)
{
...
}
Here's the same function definition coded in Node.js, showing how the bound route parameter values can be accessed via context.bindingData
:
module.exports = function (context, req) {
var category = context.bindingData.category;
var id = context.bindingData.id;
...
}
By default, all function routes will be prefixed with api
. You can customize or remove that prefix entirely via the http.routePrefix
property of function.json
, e.g.:
{
"http": {
"routePrefix": ""
}
}
Here we've set this to an empty string which means that no prefix will be used. So rather than http://<yourapp>.azurewebsites.net/api/<funcname>
the default route for functions in the app will be http://<yourapp>.azurewebsites.net/<funcname>
.
- Configuration Settings
- function.json
- host.json
- host.json (v2)
- Http Functions
- Function Runtime Versioning
- Official Functions developers guide
- Host Health Monitor
- Managing Connections
- Renaming a Function
- Retrieving information about the currently running function
- Site Extension Resolution
- Linux Consumption Regions
- Using LinuxFxVersion for Linux Function apps
- Out-of-proc Cancellation Tokens
- Assembly Resolution in Azure Functions
- ILogger
- Precompiled functions
- Official Functions C# developer reference
- Contributor Onboarding
- Development Process
- Deploying the Functions runtime as a private site extension
- Authoring & Testing Language Extensions
- Bindings in out-of-proc
- Language Extensibility
- Worker Capabilities
- Investigating and reporting issues with timer triggered functions not firing
- Sharing Your Function App name privately
- Azure Functions CLI release notes [moved here]
- Function App Zipped Deployment [deprecated]