如何在Azure函数中使用ServiceBusTrigger配置不同的预取设置?

huangapple go评论57阅读模式
英文:

How can you configure different prefetch settings using ServiceBusTrigger in a azure function

问题

今天我在startup.cs中配置PrefetchCount,如下所示。但是,我们在同一个项目中使用ServiceBusTrigger的多个函数。如何为每个函数配置不同的PrefetchCount?

builder.Services.Configure((ServiceBusOptions options) =>
{
    options.PrefetchCount = 20;
});

请注意:您需要在每个函数的配置中设置不同的PrefetchCount,以实现为每个函数配置不同的值。

英文:

Today i'm configuring PrefetchCount in startup.cs like below. However, we have multiple functions using the ServiceBusTrigger in the same project. How can I configure different PrefetchCount for each function?

builder.Services.Configure((ServiceBusOptions options) =>
{
	options.PrefetchCount = 20;
});

答案1

得分: 1

"Function App is configuration is applied to all Functions hosted in the same application. If you need to configure functions differently, you'll need to deploy those functions separately."

"Function App 的配置适用于托管在同一应用程序中的所有函数。如果您需要不同配置函数,您需要单独部署这些函数。"

英文:

Function App is configuration is applied to all Functions hosted in the same application. If you need to configure functions differently, you'll need to deploy those functions separately.

答案2

得分: 1

  • 正如由 @MikhailShilkov 在此 答案MS 文档 中指定的,如果您在 host.json 代码中定义了 PrefetchCount,那么它将作为 Azure 函数项目中所有函数的全局配置。

> 我如何为每个函数配置不同的 PrefetchCount?

  • 如果所有函数都是相同的触发器类型,那么微软推荐的方式是在 host.json 中定义该设置,如果它是函数级别的代码设置,那么我们可以像函数禁用属性一样在函数代码中定义,这是由 @SeanFeldman 在此 答案 中提出的。
英文:
  • As specified in this SO Answer given by @MikhailShilkov and MS Doc, if you define the PrefetchCount in host.json code, then it acts as a global configuration for all the functions in an Azure function project.

> How can I configure different PrefetchCount for each function?

  • If all the functions are of same trigger type, then the recommended way by Microsoft is to define that setting in host.json and if it is function level code setting, then we can define in the Function Code like Function Disable attribute, it is proposed by @SeanFeldman in this SO answer.

huangapple
  • 本文由 发表于 2023年1月9日 16:58:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75054995.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定