HttpTrigger.route Method


Defines the route template, controlling which request URLs your function will respond to. The default value if no route is provided is the function name specified in the FunctionName annotation, applied to each Azure Function.

By default when you create a function for an HTTP trigger, or WebHook, the function is addressable with a route of the form http://<yourapp><funcname>. You can customize this route using this route property. For example, a route of "products/{category:alpha}/{id:int}" would mean that the function is now addressable with the following route instead of the original route: http://<yourapp>, which allows the function code to support two parameters in the address: category and id. By specifying the route in this way, developers can then add the additional route arguments as arguments into the function by using the BindingName annotation. For example:

  public HttpResponseMessage<String> routeTest(
      @HttpTrigger(name = "req",
                    methods = {HttpMethod.GET},
                    authLevel = AuthorizationLevel.ANONYMOUS,
                    route = "products/{category:alpha}/{id:int}") 
                    HttpRequestMessage<Optional<String>> request,
      @BindingName("category") String category,
      @BindingName("id") int id,
       final ExecutionContext context
  ) {
           context.getLogger().info("We have " + category + " with id " + id);

For more details on the route syntax, refer to the online documentation.

public abstract String route()



The route template to use for the annotated function.

Applies to