我有一个简单的 .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 …
轻松复制
引入了重大变化 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)
我遇到了以下问题:
问题:
提前致谢!
我正在尝试创建一个每 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 …
我想将当前的 webjobs 配置重写为 3.0 版本,但我无法让它与文档一起使用,因为我不知道如何设置dashboardconnectionstring或storageconnectionstring不设置配置文件。
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)
我想让它使用正确的存储和仪表板连接字符串连续运行,而不使用配置文件。