我有一个连接到服务总线队列的 Azure Function。它接收消息并生成记录以保存在 Azure 表存储中。
服务总线队列当前有大量消息:
由于有很多待处理的消息,我预计 Azure Functions 会发生扩展,但情况似乎并非如此:
该函数只有一个实例正在运行,我希望有更多实例可以帮助清空队列。
如 Azure Function's documentation on scaling 中所述使用服务总线时,我确保 Azure 函数使用的策略包括管理权限以帮助扩展:
问题
为什么我的 Azure Functions 在消费计划上运行时无法扩展以帮助从服务总线中取出所有消息?
更新
以下是 Azure 函数的摘录:
public static class RecordImporter
{
private static readonly IImporter Importer;
static RecordImporter()
{
Importer = new AzureTableImporter();
}
[FunctionName("Importer")]
public static async Task Run([ServiceBusTrigger("records ", Connection = "serviceBusConnectionString")] string serializedRecords, ILogger log)
{
var records = JsonConvert.DeserializeObject<List<Record>>(serializedRecords);
await Importer.AddRecordsAsync(records);
}
}
最佳答案
只是一个想法,因为有些人在服务总线触发横向扩展方面面临类似的问题:
https://github.com/microsoft/azure-pipelines-tasks/issues/6759
我注意到您使用的是 C#,因此请在发布时执行此操作:
(清除“从包文件运行”复选框。VS默认使用Zip部署,可以通过上述步骤更改为Web部署。)
关于c# - 为什么我的 Azure Functions 在消费计划上运行时无法扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62343591/