Using .NET Core 2.0 Libraries in WebJob Targeting .NET Framework 4.7

风格不统一 提交于 2019-12-01 13:50:12

According to your description, I suggest you could try to use net core2.0 console application to create the web job.

1.Created the net core 2.0 project.

Then install the Microsoft.Azure.WebJobs(3.0.0-beta2) from Nuget Package manager.

2.Change the console application's main method codes as below:

using Microsoft.Azure.WebJobs; using System; using System.IO;

namespace NetCore2Webjob
{
    class Program
    {
        static void Main(string[] args)
        {
            Environment.SetEnvironmentVariable("AzureWebJobsDashboard", "connection");
            Environment.SetEnvironmentVariable("AzureWebJobsStorage", "storage connection");
            var config = new JobHostConfiguration();

            if (config.IsDevelopment)
            {
                config.UseDevelopmentSettings();
            }

            var host = new JobHost(config);
            host.RunAndBlock();
        }


    }
    public class Functions
    {
        public static void ProcessQueueMessage([QueueTrigger("myqueue")] string message, TextWriter log)
        {
            log.WriteLine(message);
        }
    }
}

3.Click publish to publish the console application.

4.Locate the publishoutput folder and created a run.cmd file.

Use the notepad to open the run.cmd and add below codes:

dotnet {yourporjectname}.dll

Example:

dotnet NetCore2Webjob.dll

5.Compress the whole publishoutput folder as zip file.

6.Open webjobs portal and upload this zip.

7.Wait the web app installed the webjob

Result:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!