3

My goal is to provide a code snippet to customers. One file will contain customer's business logic, another file will provide its handling. For the latter I need to have a name of a function [would like to avoid asking customers to enter this information manually].

I searched around but could not figure out. Essentially I need this:

enter image description here

ZakiMa
  • 5,637
  • 1
  • 24
  • 48

1 Answers1

9

The ExecutionContext class has a property FunctionName (docs)

You can inject the class like this:

[FunctionName("HttpTriggered")]
public IActionResult Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
     HttpRequest req, 
     ExecutionContext executionContext)
{
     var name = executionContext.FunctionName;
     ...
}

The output will be

HttpTriggered

Peter Bons
  • 26,826
  • 4
  • 50
  • 74