使用VS 2017 15.3在.NET Core中运用Azure WebJobs

6
我刚安装了 Visual Studio 2017 15.3 的预览版,但我仍然找不到在 .NET Core 中创建 WebJobs 的方法。这是否可用 - 即使是作为预览或测试版?PS:这不是管理员建议的重复问题。我只是想说在其他帖子中提出的建议没有起作用。

enter image description here


1
可能是.NET Core中的Azure WebJob的重复问题。 - Venkata Dorisala
1个回答

0

使用.NET Core框架创建WebJob的方式有些不同。您需要使用控制台应用程序(.NET Core)

我强烈建议您遵循这个指南.NET Core中的Azure WebJobs



这是我的简单WebJob工作示例:(使用Core 2.2)

(程序)

public class Program
{
    public static IConfigurationRoot config { get; private set; }

    static void Main(string[] args)
    {
        var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
        Console.WriteLine($"Current Environment : {(string.IsNullOrEmpty(environment) ? "Development" : environment)}");

        config = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                .AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
                .AddEnvironmentVariables()
                .Build();

        Console.WriteLine("URL API:" + config["appsettings node"]);


        var builder = new HostBuilder()
            .ConfigureWebJobs(webJobConfiguration =>
            {
                webJobConfiguration.AddTimers();
                webJobConfiguration.AddAzureStorageCoreServices();
            })
            .ConfigureServices(serviceCollection => serviceCollection.AddSingleton<TimeneyeTasks>())
            .Build();

        builder.Run();
    }
}

我的类:) {{link1:输入图像描述}}

希望能对你有所帮助!


1
请勿发布代码截图,直接发布文字! - slfan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接