Azure策略-检查是否有任何预算分配给订阅

y53ybaqx  于 2023-04-07  发布在  其他
关注(0)|答案(1)|浏览(124)

如何编写Azure策略,如果订阅分配了预算,将进行审计。如果没有分配给订阅的预算,我希望策略处于“不符合”状态。
我已尝试使用AuditINotExists进行检查

{
      "mode": "All",
      "policyRule": {
        "if": {
          "field": "type",
          "equals": "Microsoft.Consumption/budgets"
        },
        "then": {
          "effect": "auditIfNotExists",
          "details": {
            "type": "Microsoft.Consumption/budgets",
            "name": "budget"
          }
        }
      },
      "parameters": {}
}
ccrfmcuu

ccrfmcuu1#

以下策略将审核订阅,检查是否分配了预算。如果分配了预算,则认为订阅合规,如果没有分配预算,则认为订阅不合规

{
  "mode": "All",
  "policyRule": {
    "if": {
      "field": "type",
      "equals": "Microsoft.Consumption/budgets"
    },
    "then": {
      "effect": "auditIfNotExists",
      "details": {
        "type": "Microsoft.Consumption/budgets",
        "existenceCondition": {
          "field": "Microsoft.Consumption/budgets/amount",
          "exists": "true"
        }
      }
    }
  },
  "parameters": {}
}

输出:

参考:Create and manage Azure budgets

相关问题