更新时间:2023-02-11 16:00:04
根据您的描述,我建议您可以尝试这样做使用net core2.0控制台应用程序创建Web作业。
According to your description, I suggest you could try to use net core2.0 console application to create the web job.
1。创建了net core 2.0项目。
1.Created the net core 2.0 project.
然后从Nuget软件包管理器安装Microsoft.Azure.WebJobs(3.0.0-beta2)。
Then install the Microsoft.Azure.WebJobs(3.0.0-beta2) from Nuget Package manager.
2。更改控制台应用程序的主要方法代码,如下所示:
2.Change the console application's main method codes as below:
使用Microsoft.Azure.WebJobs;
使用系统;
使用System.IO;
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。单击发布以发布控制台应用程序。
3.Click publish to publish the console application.
4。找到publishoutput文件夹并创建run.cmd文件。
4.Locate the publishoutput folder and created a run.cmd file.
使用记事本打开run.cmd并添加以下代码:
Use the notepad to open the run.cmd and add below codes:
dotnet {yourporjectname}.dll
示例:
dotnet NetCore2Webjob.dll
5。将整个publishoutput文件夹压缩为zip文件。
5.Compress the whole publishoutput folder as zip file.
6。打开webjobs门户并上传该zip。
6.Open webjobs portal and upload this zip.
7。等待网络应用安装了webjob
7.Wait the web app installed the webjob
结果: