我在 VNET 内的高级计划中有一个队列触发的 Azure 函数应用程序。函数和队列都在同一个 VNET 中
根据我对基于目标的缩放的理解,如果我将批量大小设置为 1 并且队列中有 5 条消息,则无论 CPU 和内存使用情况如何,我都应该获得 Function App 的 5 个实例?
类似地,如果我将 BatchSize 设置为 2,并且队列中有 10 条消息,我的函数应该扩展 5 个实例并每个处理 2 个实例,以便处理所有 10 条消息。
但是缩放并未发生。批量大小为 1 会导致一次处理 1 条消息,且不会缩放,批量大小为 2 会导致并发数为 2(如预期),不会缩放...实例大小仍为 1。
我错过了什么?文档状态默认情况下启用基于目标的缩放...是否有任何我应该检查的特定设置?
处于 VNET 中对基于目标的扩展有任何影响吗?
在 Azure Functions Premium 计划中,实例的默认设置为 1。
请参阅此 MSDOC,了解有关 Azure Functions Premium 中实例的信息。
实例:
弹性扩展:
Azure 应用程序见解输出:
let grainTime = 30sec;
traces
| where timestamp >= ago(24h)
| summarize ['rate/minute'] = dcount(cloud_RoleInstance) by bin(timestamp, grainTime)
您可以通过以下命令使用 Azure CLI
set/Upadate
Azure Functions Premium 计划中的实例数量:
az functionapp update -g <RESOURCE_GROUP> -n <FUNCTION_APP_NAME> --set siteConfig.minimumElasticInstanceCount=<YOUR_ALWAYS_READY_COUNT>
现在实例增加到
5
:
之后,我按照此链接使用REST API获取应用程序服务的列表实例标识符。
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/instances?api-version=2023-12-01
Authorization: Bearer<tokem>
输出:
批量:
您可以将
batchSize
中的host.json
设置为2,如下所示:{
"version": "2.0",
"extensions": {
"queues": {
"batchSize": 2
}
},