0

I have a bunch of Azure functions that use an http trigger. I've been hard-coding http methods like in the below case:

[FunctionName("HttpTriggerCSharp")]
public static async Task<IActionResult> Run(
    [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
    HttpRequest req, ILogger log)

Ideally, I'd like to use a strongly typed value instead of hard-coded strings like get and post. I tried using HttpMethod enum values, but I'm getting the below error:

An attribute argument must be a constant expression , typeof expression or array creation expression of an attribute parameter type

Using C#, is there a way to leverage strongly typed http methods when declaring the function method signature?

user246392
  • 2,661
  • 11
  • 54
  • 96

1 Answers1

4

nameof(HttpMethod.Get) should work.

Machiel Visser
  • 905
  • 4
  • 8