c# - 为什么我的 Azure Functions 在消费计划上运行时无法扩展?

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

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

服务总线队列当前有大量消息:

Service Bus queue

由于有很多待处理的消息,我预计 Azure Functions 会发生扩展,但情况似乎并非如此:

Azure Function metrics

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

Azure Function's documentation on scaling 中所述使用服务总线时,我确保 Azure 函数使用的策略包括管理权限以帮助扩展:

Service bus queue policy

问题

为什么我的 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#,因此请在发布时执行此操作:

enter image description here

enter image description here

enter image description here

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

关于c# - 为什么我的 Azure Functions 在消费计划上运行时无法扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62343591/

相关文章:

c# - Entity Framework 抛出无法在表中插入标识列的显式值

c# - 尝试将数据插入 SQLite 时出错

c# - AutoFac DbContext 问题 - 在创建模型时无法使用

c# - 使用数组属性绑定(bind)模型以在 ASP.NET Core MVC 中形成

c# - 从 asp.net core 身份验证 Web 应用程序获取 Microsoft Graph 的访问 token

c# - 在嵌入式 XP 上使用 WPF 实现简单的 GUI

windows - 如果 OnStart() 引发异常,我可以要求 Azure 运行时不要重新启动我的角色吗?

c# - 即使具有正确的权限和 Nuget 身份验证任务,Azure Pipeline 也无法访问 Azure Artefact Nuget 项目源

Azure - 如何列出 Azure 中的所有 Databricks 工作区

visual-studio - 通过 visual studio 2017 中的 postbuild 事件构建 .net 核心项目