none
Azure Functions entry point method

    Question

  • I'm using C#. The OOTB csx file has a Run method that gets invoked. I've seen other examples where the method that is invoked has another name.

    How does Azure Functions determine which method it will invoke when the function is triggered? I'm not seeing anything in the function.json file that allows for configuration.

    Friday, October 28, 2016 2:13 PM

Answers

  • Hello,

    The function entry point defaults to "Run" but is indeed configurable.

    You can add an "entryPoint" property to your function.json file to override that value:

    {
      "entryPoint" : "MyMethodName"
    }

    To answer your question (and for the curious), the current logic is the following:

    • If an entry point is explicitly set (using the property described above), the runtime will attempt to locate that method and fail if it isn't defined
    • Otherwise; if there's a single public method defined, that will be used regardless of the name
    • Otherwise (if there are multiple public methods); the runtime will attempt to locate a method with the default name of "Run"

    By the way; aside from the access modifier, Node uses the same exact logic (but looks for "run" or "index")

    And if you are really curious, you can actually look at the (conveniently named) FunctionEntryPointResolver source here

    Hope this helps!


    Friday, October 28, 2016 5:14 PM

All replies

  • Hello,

    The function entry point defaults to "Run" but is indeed configurable.

    You can add an "entryPoint" property to your function.json file to override that value:

    {
      "entryPoint" : "MyMethodName"
    }

    To answer your question (and for the curious), the current logic is the following:

    • If an entry point is explicitly set (using the property described above), the runtime will attempt to locate that method and fail if it isn't defined
    • Otherwise; if there's a single public method defined, that will be used regardless of the name
    • Otherwise (if there are multiple public methods); the runtime will attempt to locate a method with the default name of "Run"

    By the way; aside from the access modifier, Node uses the same exact logic (but looks for "run" or "index")

    And if you are really curious, you can actually look at the (conveniently named) FunctionEntryPointResolver source here

    Hope this helps!


    Friday, October 28, 2016 5:14 PM
  • I appreciate the detailed explanation!

    Unless I read the code wrong, I believe the answer to the following question is "no".

    If I deploy a private assembly in the bin folder, is there a way to use one of its methods as an entry point (even if it has to be static)?

    I've already got it working where I have a Run method in the csx that simply invokes a method in my private assembly, so that's fine, but if there's a way to obviate the use of a csx file, that would be nice.

    Friday, October 28, 2016 8:20 PM
  • That is correct. Currently, that is not supported, but it is a scenario we intend to support in the future.

    -Fabio

    Friday, October 28, 2016 9:48 PM