为什么我在消费计划上运行的Azure功能无法扩展?

时间:2020-06-12 11:43:55

标签: c# azure .net-core azure-functions

我有一个连接到服务总线队列的Azure函数。它会收到一条消息并生成记录以保存在Azure Table存储中。

服务总线队列当前有很多消息:

Service Bus queue

由于有许多待处理的消息,所以我希望Azure功能可以进行扩展,但是事实并非如此:

Azure Function metrics

只有一个正在运行的Function实例,我希望有更多实例可以帮助清空队列。

使用服务总线时,如Azure Function's documentation on scaling中所指定,我确保Azure功能使用的策略包括“管理”权限以帮助扩展:

Service bus queue policy

问题

为什么我在消费计划上运行的Azure功能无法扩展以帮助从服务总线中取出所有消息?

更新

以下是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);
    }
}

1 个答案:

答案 0 :(得分:0)

这只是一个主意,因为有些人在服务总线触发横向扩展时会遇到类似的问题:

https://github.com/microsoft/azure-pipelines-tasks/issues/6759

我注意到您正在使用C#,因此在发布时请执行以下操作:

enter image description here

enter image description here

enter image description here

(清除“从包文件运行”复选框。默认情况下,VS使用Zip部署,可以通过上述步骤将其更改为Web部署。)