C# Azure功能应用程序C.NET 2.0-共享代码

C# Azure功能应用程序C.NET 2.0-共享代码,c#,azure-functions,C#,Azure Functions,我有一个Azure Function应用程序,将有大约5个功能。我正在使用C.NETCore2.0。我正在Visual Studio中进行所有开发,并将应用程序发布到Azure。我见过使用.csx文件共享代码的例子,这些代码使用门户和.NET4.61。我想知道如何在.NETCore2.0中在VisualStudio中进行开发。非常感谢您的帮助。玩过之后,我想我找到了答案 功能应用程序结构 MyFunctionApp Func1 Folder ---Func1.cs

我有一个Azure Function应用程序,将有大约5个功能。我正在使用C.NETCore2.0。我正在Visual Studio中进行所有开发,并将应用程序发布到Azure。我见过使用.csx文件共享代码的例子,这些代码使用门户和.NET4.61。我想知道如何在.NETCore2.0中在VisualStudio中进行开发。非常感谢您的帮助。

玩过之后,我想我找到了答案

功能应用程序结构

    MyFunctionApp
    Func1 Folder
    ---Func1.cs
    Func2 Folder
    ---Func2.cs
    Func3 Folder
    ---Func3.cs
    Func4 Folder
    ---Func4.cs
    Shared Folder
    ---Utils.cs
Func1/Func1.cs

    //Func1/Func1.cs
    using static MyNameSpace.Shared.Utils;
    using System;
    using Microsoft.Azure.WebJobs;
    using Microsoft.Azure.WebJobs.Host;
    using Microsoft.Extensions.Logging;

    namespace MyNameSpace
    {
        public static class Func1
        {
            [FunctionName("Func1")]
            public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
            {
                log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
                int x = MyAdd(5, 7);
                log.LogInformation($"Result: {x}");
            }
        }
    }
共享/Utils.cs

   //Shared/Utils.cs
    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace MyNameSpace.Shared
    {
        static class Utils
        {
            public static int MyAdd(int num1, int num2)
            {
                return num1 + num2;
            }
        }
    }

“共享代码”是什么意思?当您从VS部署预编译DLL时,您不会像在Azure门户中编写代码那样在门户中看到源代码。无论是.NET核心还是.NET框架,这都是独立的。