从 Azure ServiceBus 基础结构调用 WebJob(不要连续 运行 WebJob)
Invoke WebJob from Azure ServiceBus infrastructure (don't run WebJob continuously)
我正在尝试找出是否可以 运行 手动安排的网络作业,并在消息到达服务总线队列时启动它。
所以 webjob 不会 运行 连续,只有当消息到达时。
(从而节省资源成本)
到目前为止我尝试了什么:
在Program.cs
public static async Task Main()
{
JobHostConfiguration config = new JobHostConfiguration();
_servicesBusConnectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration();
config.UseServiceBus(serviceBusConfig);
JobHost host = new JobHost(config);
Console.WriteLine("Starting host");
host.RunAndBlock();
}
在Functions.cs
public static void SBQueue2SBQueue([ServiceBusTrigger("createinvoice")] string start)
{
Console.WriteLine("Receiving a message");
}
还有一个 run.cmd 来启动进程
@echo off
dotnet CoreConsoleWebJob.dll
但是,在此解决方案中,我从 Azure 控制台启动了手动触发的 Web 作业。 host.RunAndBlock();阻塞线程,但一段时间后进程失败,因为它空闲时间太长,web 作业被关闭。
进程是否有可能被 azure servicebus 基础设施调用?或者是一个连续的网络工作总是要走的路。
提前致谢!
应用服务计划中的 Web 作业 运行。由于您已经为 App Service Plan 付费,如果不连续使用 webjob 运行,您将无法节省任何资金。如果您正在考虑省钱,请查看 运行 将此作为 Azure Function on a Consumption Plan。
确实 省钱,因为您只需在功能 运行 时付费。触发器开箱即用,这很好:)
When you're using a Consumption plan, instances of the Azure Functions host are dynamically added and removed based on the number of incoming events. This serverless plan scales automatically, and you're charged for compute resources only when your functions are running.
我正在尝试找出是否可以 运行 手动安排的网络作业,并在消息到达服务总线队列时启动它。
所以 webjob 不会 运行 连续,只有当消息到达时。 (从而节省资源成本)
到目前为止我尝试了什么:
在Program.cs
public static async Task Main()
{
JobHostConfiguration config = new JobHostConfiguration();
_servicesBusConnectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.ServiceBus);
ServiceBusConfiguration serviceBusConfig = new ServiceBusConfiguration();
config.UseServiceBus(serviceBusConfig);
JobHost host = new JobHost(config);
Console.WriteLine("Starting host");
host.RunAndBlock();
}
在Functions.cs
public static void SBQueue2SBQueue([ServiceBusTrigger("createinvoice")] string start)
{
Console.WriteLine("Receiving a message");
}
还有一个 run.cmd 来启动进程
@echo off
dotnet CoreConsoleWebJob.dll
但是,在此解决方案中,我从 Azure 控制台启动了手动触发的 Web 作业。 host.RunAndBlock();阻塞线程,但一段时间后进程失败,因为它空闲时间太长,web 作业被关闭。
进程是否有可能被 azure servicebus 基础设施调用?或者是一个连续的网络工作总是要走的路。
提前致谢!
应用服务计划中的 Web 作业 运行。由于您已经为 App Service Plan 付费,如果不连续使用 webjob 运行,您将无法节省任何资金。如果您正在考虑省钱,请查看 运行 将此作为 Azure Function on a Consumption Plan。
确实 省钱,因为您只需在功能 运行 时付费。触发器开箱即用,这很好:)
When you're using a Consumption plan, instances of the Azure Functions host are dynamically added and removed based on the number of incoming events. This serverless plan scales automatically, and you're charged for compute resources only when your functions are running.