相关疑难解决方法(0)

警告:仅从程序集中获取部分类型:Microsoft.Azure.WebJobs.Extensions.Storage

我有一个简单的 .NET V3 WebJob,在 .NET 网站中启动并运行了一个计时器触发器,如本答案所述:Scheduled .NET WebJob V3 example

但是,在输出中,我收到此警告:

warn: Host.Startup[0] Warning: Only got partial types from assembly: Microsoft.Azure.WebJobs.Extensions.Storage, Version=3.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 The following loader failures occured when trying to load the assembly: - Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. - Method 'Commit' in type 'Microsoft.Azure.WebJobs.Host.Blobs.Bindings.DelegatingCloudBlobStream' from assembly 'Microsoft.Azure.WebJobs.Extensions.Storage, Version=3.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation. - Method 'Commit' in …

c# asp.net azure azure-webjobs azure-webjobssdk

11
推荐指数
1
解决办法
558
查看次数

新的Azure WebJob项目 - 在NuGet更新后缺少JobHostConfiguration/RunAndBlock

轻松复制

  1. 创建一个新项目'ASP.NET Web应用程序(.NET Framework).
  2. 构建编译,更新NuGet,一切正常.
  3. 添加:添加新的Azure WebJob项目.
  4. 构建,编译.快乐
  5. 更新WebJob项目的NuGet.
  6. 项目不再编译.

引入了重大变化 https://github.com/Azure/app-service-announcements/issues/129

所以我安装

Microsoft.Azure.WebJobs.Extensions.Storage

这解决了QueueTriggerAttribute

但是在program.cs中

    static void Main()
    {
        var config = new JobHostConfiguration();

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

        var host = new JobHost(config);
        host.RunAndBlock();
    }
Run Code Online (Sandbox Code Playgroud)

我遇到了以下问题:

  1. 现在缺少JobHostConfiguration.
  2. JobHost构造函数现在有两个参数,包括一个新的IJobHostContextFactory?
  3. RunAndBlock丢失了.它现在是'StartAsync'
  4. 现在代码需要变为异步,因为没有对作业的同步调用.

问题:

  1. 需要安装哪些additioanl组件?
  2. 什么是这个新的JobHostContextFactory?
  3. 我现在如何配置作业?
  4. 我该如何更新异步代码?
  5. 现在我们拥有的只是Start,我如何阻止连续工作?

提前致谢!

  • C#
  • .Net Framework 4.6.2
  • Visual Studio 2017 - v15.8.7

c# azure azure-webjobs

10
推荐指数
1
解决办法
2804
查看次数

Azure WebJobs SDK TimerTrigger 函数未运行

我正在尝试创建一个每 x 秒运行一个函数的 Azure WebJob。我正在关注Microsoft 网站上的教程以及Github上如何将 TimerTrigger 与 WebJobs 结合使用的示例。但是,当我在本地运行时,Functions.cs 中的方法似乎没有运行(没有日志记录并且没有命中断点)。

程序.cs:

public class Program
    {
        static async Task Main()
        {
            var builder = new HostBuilder();
            builder.ConfigureWebJobs(b =>
            {
                b.AddAzureStorageCoreServices();
            });
            var host = builder.Build();
            using (host)
            {
                await host.RunAsync();
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

函数.cs:

public class Functions
    {

        public static void TimerJob([TimerTrigger("00:00:03", RunOnStartup = true)] TimerInfo timer)
        {
            Console.WriteLine("Timer job fired!");
        }
    }
Run Code Online (Sandbox Code Playgroud)

我在调试控制台中的唯一输出是:

Hosting environment: Production
Content root path: C:\Users\<blah>\<Project\bin\Debug\net472\
Run Code Online (Sandbox Code Playgroud)

这是我的 nuget 软件包和版本:

在此输入图像描述

我正在使用 .NET …

c# azure-webjobs azure-webjobssdk

3
推荐指数
1
解决办法
2442
查看次数

Azure webjobs JobHostConfiguration 丢失,现在无法进行设置

我想将当前的 webjobs 配置重写为 3.0 版本,但我无法让它与文档一起使用,因为我不知道如何设置dashboardconnectionstringstorageconnectionstring不设置配置文件。

JobHostConfiguration config = new JobHostConfiguration
{
    NameResolver = new WebJobsNameResolver()
};

string defaultStorageConnectionString = string.Format( "Some dynamically generation string" );
config.DashboardConnectionString = defaultStorageConnectionString;
config.StorageConnectionString = defaultStorageConnectionString;

using(JobHost host = new JobHost(config))
{
    // The following code ensures that the WebJob will be running continuously
    host.RunAndBlock();
}
Run Code Online (Sandbox Code Playgroud)

我想让它使用正确的存储和仪表板连接字符串连续运行,而不使用配置文件。

.net c# azure azure-webjobssdk

2
推荐指数
1
解决办法
4269
查看次数

标签 统计

c# ×4

azure ×3

azure-webjobs ×3

azure-webjobssdk ×3

.net ×1

asp.net ×1