你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az monitor autoscale rule

管理自动缩放缩放规则。

有关自动缩放的详细信息,请访问: https://docs.microsoft.com/azure/monitoring-and-diagnostics/monitoring-understanding-autoscale-settings

命令

名称 说明 类型 状态
az monitor autoscale rule copy

将自动缩放规则从一个配置文件复制到另一个配置文件。

核心 GA
az monitor autoscale rule create

添加新的自动缩放规则。

核心 GA
az monitor autoscale rule delete

从配置文件中删除自动缩放规则。

核心 GA
az monitor autoscale rule list

列出配置文件的自动缩放规则。

核心 GA

az monitor autoscale rule copy

将自动缩放规则从一个配置文件复制到另一个配置文件。

az monitor autoscale rule copy --autoscale-name
                               --dest-schedule
                               --index
                               --resource-group
                               [--source-schedule]

必需参数

--autoscale-name

自动缩放设置的名称。

--dest-schedule

要复制到的配置文件的名称。

--index

要复制的规则索引的空格分隔列表,或复制所有规则的“*”。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--source-schedule

要从中复制规则的配置文件的名称。

默认值: default
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az monitor autoscale rule create

添加新的自动缩放规则。

有关自动缩放的详细信息,请访问: https://docs.microsoft.com/azure/monitoring-and-diagnostics/monitoring-understanding-autoscale-settings

az monitor autoscale rule create --autoscale-name
                                 --condition
                                 --scale
                                 [--cooldown]
                                 [--profile-name]
                                 [--resource]
                                 [--resource-group]
                                 [--resource-namespace]
                                 [--resource-parent]
                                 [--resource-type]
                                 [--timegrain]

示例

当跨实例的 CPU 百分比超过 75 分钟平均超过 10 分钟时,缩放到 5 个实例。

az monitor autoscale rule create -g {myrg} --autoscale-name {myvmss} \
  --scale to 5 --condition "Percentage CPU > 75 avg 10m"

当跨实例的 CPU 百分比超过 75 分钟时,纵向扩展 2 个实例。

az monitor autoscale rule create -g {myrg} --autoscale-name {myvmss} \
  --scale out 2 --condition "Percentage CPU > 75 avg 5m"

当跨实例的 CPU 百分比小于 25 分钟的平均 CPU 百分比时,纵向缩减 50%。

az monitor autoscale rule create -g {myrg} --autoscale-name {myvmss} \
  --scale in 50% --condition "Percentage CPU < 25 avg 15m"

通过诊断扩展启用的来宾 VM 指标创建自动缩放设置。 可以在“--condition”中使用从“az vmss 诊断 get-default-config”中检索的 counterSpecifier 字段。

az monitor autoscale rule create -g {myrg} --autoscale-name test --scale out 1 --condition "/builtin/memory/percentavailablememory > 80 total 5m"

必需参数

--autoscale-name

自动缩放设置的名称。

--condition

触发缩放操作的条件。

用法:--condition [“NAMESPACE”] METRIC {==,!=,>,>=,<=,<=} THRESHOLD {avg,min,max,total,count} PERIOD [where DIMENSION {==,!=} VALUE [or VALUE ...][and DIMENSION {==,!=} VALUE [or VALUE ...] ]

可以通过添加“where”关键字 (keyword)和多个维度来查询维度,方法是将它们与“and”关键字 (keyword)组合在一起。 可以从命令中获取 az monitor metric METRIC 值和适当的阈值值。 PERIOD 的格式为“##h##m##s”。

--scale

方向和缩放量。

使用情况:--scale {to,in,out} VAL[%] 固定计数: --scale to 5 In by Count: --scale in 2 Out by Percent: --scale out 10%。

可选参数

--cooldown

在发生另一个缩放事件之前必须经过的分钟数。

默认值: 5
--profile-name

自动缩放配置文件的名称。

默认值: default
--resource

目标资源的名称或 ID。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--resource-namespace

目标资源提供程序命名空间。

--resource-parent

目标资源父路径(如果适用)。

--resource-type

目标资源类型。 还可以接受命名空间/类型格式(例如:“Microsoft.Compute/virtualMachines”。

--timegrain

指标在实例之间轮询的方式。

timegrain 的格式为 {avg,min,max,sum} VALUE。 可以从命令获取 az monitor metric 值。 VALUE 的格式为“##h##m##s”。

默认值: avg 1m
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az monitor autoscale rule delete

从配置文件中删除自动缩放规则。

az monitor autoscale rule delete --autoscale-name
                                 --index
                                 --resource-group
                                 [--profile-name]

必需参数

--autoscale-name

自动缩放设置的名称。

--index

要删除的规则索引的空格分隔列表,或“*”清除所有规则。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--profile-name

自动缩放配置文件的名称。

默认值: default
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az monitor autoscale rule list

列出配置文件的自动缩放规则。

az monitor autoscale rule list --autoscale-name
                               --resource-group
                               [--profile-name]

示例

列出配置文件的自动缩放规则。 (自动生成)

az monitor autoscale rule list --autoscale-name MyAutoscale --profile-name MyProfile --resource-group MyResourceGroup

必需参数

--autoscale-name

自动缩放设置的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--profile-name

自动缩放配置文件的名称。

默认值: default
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。