简体   繁体   English

为什么我的 Azure Function 在消耗计划上运行而不是扩展?

[英]Why is my Azure Function running on a Consumption Plan not scaling?

I have an Azure Function that is hooked up to a Service Bus queue.我有一个连接到服务总线队列的 Azure Function。 It receives a message and generates records to save in an Azure Table storage.它接收消息并生成记录以保存在 Azure 表存储中。

The Service Bus queue currently has a lot of messages: Service Bus 队列当前有很多消息:

服务总线队列

Since there are a lot of pending messages, I would expect the scaling of the Azure Functions to happen, however it does not seem to be the case:由于有很多待处理的消息,我希望 Azure 函数的缩放会发生,但似乎并非如此:

Azure 函数指标

There is only one instance of the Function running and I expected more to help empty the queue.只有一个 Function 实例正在运行,我希望有更多实例可以帮助清空队列。

As specified in the Azure Function's documentation on scaling when using a service bus, I made sure the policy used by the Azure Function included the Manage rights to help scaling:正如Azure 函数关于使用服务总线时进行缩放的文档中所述,我确保 Azure Function 使用的策略包括帮助缩放的管理权限:

服务总线队列策略

Question问题

Why is my Azure Function running on a Consumption Plan not scaling to help dequeue all the messages from the Service Bus?为什么我的 Azure Function 在消耗计划上运行不能扩展以帮助从服务总线中取出所有消息?

Update更新

Here is an extract of the Azure Function:这是 Azure Function 的摘录:

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);
    }
}

Just an idea, because some people face the similar problem with service bus trigger scale out:只是一个想法,因为有些人面临服务总线触发器扩展的类似问题:

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

I notice you are using C#, so please do this when publish:我注意到您使用的是 C#,所以请在发布时执行此操作:

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

(Clear the Run from package file check box. By default, VS uses Zip deployment, which can be changed to Web deployment through the above steps.) (清除从 package 文件中运行复选框。默认情况下,VS 使用 Zip 部署,可通过上述步骤更改为 Web 部署。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM