You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否基于内存使用量对Azure Container App进行弹性伸缩?

基于内存使用量实现Azure Container App弹性伸缩的解决方案

可以基于内存使用量对Azure Container App进行弹性伸缩,但你在门户自定义规则界面看不到内存相关选项,是因为当前Azure门户的自定义规则UI仅开放了CPU、HTTP请求数等有限指标,内存这类指标需要通过Azure CLI或ARM模板来配置。

方式一:通过Azure CLI配置内存伸缩规则

替换命令中的占位符为你的资源信息后执行:

az containerapp update -n <容器应用名称> -g <资源组名称> --scale-rule-name memory-scale --scale-rule-type custom --scale-rule-metric memory_usage --scale-rule-value 70 --scale-rule-scale-out 1 --scale-rule-scale-in 1
  • 说明:当容器内存使用率超过70%时,自动扩容1个副本;低于阈值时自动缩容1个副本,可根据业务需求调整阈值和副本增减数量。

方式二:通过ARM模板配置内存伸缩规则

在ARM模板的properties.template.scale.rules节点中添加以下规则配置:

"rules": [
  {
    "name": "memory-scale",
    "type": "custom",
    "trigger": {
      "metric": "memory_usage",
      "operator": "GreaterThan",
      "threshold": 70,
      "metricResourceId": "/subscriptions/<订阅ID>/resourceGroups/<资源组名称>/providers/Microsoft.App/containerApps/<容器应用名称>"
    },
    "scale": {
      "minReplicas": 1,
      "maxReplicas": 10,
      "scaleOut": {
        "count": 1
      },
      "scaleIn": {
        "count": 1
      }
    }
  }
]

部署该ARM模板即可完成内存伸缩规则的配置。

注意:确保你的容器应用已默认启用指标采集功能,这样系统才能正常获取内存使用数据用于触发伸缩动作。

内容的提问来源于stack exchange,提问作者Goran Bralo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 18:13:25