如何制作限制每个资源组创建的虚拟机数量的azure策略脚本?

问题描述 投票:0回答:1

我想制作 Azure 策略脚本,将每个资源组创建的虚拟机数量限制为最多 2 个?

下面代码块中的策略有什么问题?

{
  "mode": "All",
  "policyRule": {
    "if": {
      "allOf": [
        {
          "field": "type",
          "equals": "Microsoft.Compute/virtualMachines"
        }
      ]
    },
    "then": {
      "effect": "deny",
      "details": {
        "type": "Microsoft.Compute/virtualMachines",
        "existenceCondition": {
          "field": "count",
          "equals": "[parameters('maxVmCount')]"
        }
      }
    }
  },
  "parameters": {
    "maxVmCount": {
      "type": "Integer",
      "metadata": {
        "displayName": "Allowed Virtual Machine capacities"
      }
    }
  }
}

我想创建一个策略,允许为每个新创建的资源组创建最多两个虚拟机。

azure policy
1个回答
0
投票

你找到解决你的限制愿望了吗?我也需要同样的东西,但我被阻止了 谢谢

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.