找不到工作功能

时间:2018-07-08 08:35:03

标签: c# azure azure-functions sendgrid

我试图在Visual Studio上使用Azure函数创建计划邮件,但是这次我遇到了No Jobs函数发现错误。如何修复和发送此邮件? 我也在Azure门户上实现了此功能,并且可以正常工作。我正在尝试转换Visual Studio。

using System;
using SendGrid.Helpers.Mail;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs;


namespace FifteenMinMail
{
    public class Program
    {
        public static void Main()
        {
            JobHostConfiguration config = new JobHostConfiguration();
            config.UseTimers();
            JobHost host = new JobHost(config);
            host.RunAndBlock();
        }
    }
    public class ScheduledMail
    {

        public static Mail Run(TimerInfo myTimer, TraceWriter log)
        {
            JobHostConfiguration config = new JobHostConfiguration();
            config.UseTimers();
            JobHost host = new JobHost(config);
            var today = DateTime.Today.ToShortDateString();
            log.Info($"Generating daily report for {today} at {DateTime.Now}");

            Mail message = new Mail()
            {
                Subject = "15 DK'LIK TEST MAILI"
            };

            Content content = new Content
            {
                Type = "text/plain",
                Value = "Bu mail 15 dk da bir yinelenecektir."
            };

            message.AddContent(content);
            return message;
        }
    }
}

错误; https://imgur.com/pyyctnC

1 个答案:

答案 0 :(得分:0)

您正在混淆Web作业和Azure功能。 这些是不同但相关的技术。 如果要在Visual Studio中创建Azure功能,请查看以下内容: https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio