如何对部分类使用Azure函数

时间:2019-12-29 13:41:10

标签: c# azure-functions

我将以下Azure函数实现为跨两个文件的部分c#类。

myfunction.cs和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       
    }
}

如果MyFunction的实现位于myfunction.mypartial.cs中,则Azure Function运行时不会检测到它。

Azure函数不支持部分类吗?

1 个答案:

答案 0 :(得分:3)

我的测试成功了:

第一个文件:

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

第二个文件

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

请在GitHub上找到我的工作解决方案: https://github.com/MarkusMeyer13/PartialFunction