doorman
doorman

Reputation: 16959

How to use Azure functions with partial classes

I have the following Azure Function implemented as partial c# class which spans two files.

myfunction.cs and myfunction.mypartial.cs

public static partial class MyFunction
{        
    [FunctionName("MyFunction")]
    public static async Task<IActionResult> MyFunction(
                           [HttpTrigger(AuthorizationLevel.Function, "GET", Route = "myfunction/{id}")] HttpRequest req,
                           ILogger log, int id)
    {
       // DO SOME STUFF       
    }
}

If the implementation of MyFunction is located in myfunction.mypartial.cs it is not detected by the Azure Function runtime.

Does Azure Function not support partial classes?

Upvotes: 2

Views: 392

Answers (1)

Markus Meyer
Markus Meyer

Reputation: 3947

My test was successful:

First file:

    public static partial class Function1
{
    [FunctionName("Sample1")]
    public static async Task<IActionResult> Sample1(
        [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
        ILogger log)

Seconde file

    public static partial class Function1
{
    [FunctionName("Sample2")]
    public static async Task<IActionResult> Sample2(
        [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
        ILogger log)

Please find my working solution on GitHub: https://github.com/MarkusMeyer13/PartialFunction

Upvotes: 3

Related Questions