英文:
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
inhost.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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论