您如何将具有Azure策略的资源组部署?

发布于 2025-01-31 18:06:57 字数 1257 浏览 5 评论 0原文

下面的示例代码。这

  1. 不是正确地评估
  2. 未正确地将资源组部署到

我试图部署将资源组部署到所有订阅的策略的所有订阅中。

"policyRule": {
  "if": {
    "allOf": [
      {
        "field": "type",
        "equals": "Microsoft.Resources/subscriptions"
      }
    ]
  },
  "then": {
    "effect": "deployIfNotExists",
    "details": {
      "type": "Microsoft.Resources/resourceGroups",
      "evaluationDelay": "AfterProvisioning",
      "roleDefinitionIds": [
        "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
      ],
      "deployment": {
        "location": "canadacentral",
        "properties": {
          "mode": "incremental",
          "template": {
            "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {},
            "variables": {},
            "resources": [
              {
                "type": "Microsoft.Resources/resourceGroups",
                "apiVersion": "2021-04-01",
                "name": "myResourceGroup",
                "location": "canadacentral",
                "properties": {}
              }
            ]
          }
        }
      }
    }
  }
}

Sample code below. This is

  1. not evaluating correctly
  2. not properly deploying the resource group to all the subscriptions

I'm trying to deploy a policy that deploys resource groups to all subscriptions.

"policyRule": {
  "if": {
    "allOf": [
      {
        "field": "type",
        "equals": "Microsoft.Resources/subscriptions"
      }
    ]
  },
  "then": {
    "effect": "deployIfNotExists",
    "details": {
      "type": "Microsoft.Resources/resourceGroups",
      "evaluationDelay": "AfterProvisioning",
      "roleDefinitionIds": [
        "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
      ],
      "deployment": {
        "location": "canadacentral",
        "properties": {
          "mode": "incremental",
          "template": {
            "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {},
            "variables": {},
            "resources": [
              {
                "type": "Microsoft.Resources/resourceGroups",
                "apiVersion": "2021-04-01",
                "name": "myResourceGroup",
                "location": "canadacentral",
                "properties": {}
              }
            ]
          }
        }
      }
    }
  }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野の 2025-02-07 18:06:58

沿线的东西

"policyRule": {
  "if": {
    "field": "type",
    "equals": "Microsoft.Resources/subscriptions"
  },
  "then": {
    "effect": "deployIfNotExists",
    "details": {
      "type": "Microsoft.Resources/Subscriptions/resourcegroups",
      "roleDefinitionIds": [
        "/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
      ],
      "evaluationDelay": "AfterProvisioning",
      "existenceCondition": {
        "field": "name",
        "equals": "myResourceGroup"
      },
      "resourceGroupName": "myResourceGroup",
      "deploymentScope": "subscription",
      "deployment": {
        "location": "canadacentral",
        "properties": {
          "mode": "incremental",
          "template": {
            "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {},
            "variables": {},
            "resources": [
              {
                "name": "myResourceGroup",
                "type": "Microsoft.Resources/resourceGroups",
                "apiVersion": "2019-10-01",
                "location": "canadacentral"
              }
            ],
            "outputs": {}
          }
        }
      }
    }
  }
}

Something along the lines

"policyRule": {
  "if": {
    "field": "type",
    "equals": "Microsoft.Resources/subscriptions"
  },
  "then": {
    "effect": "deployIfNotExists",
    "details": {
      "type": "Microsoft.Resources/Subscriptions/resourcegroups",
      "roleDefinitionIds": [
        "/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
      ],
      "evaluationDelay": "AfterProvisioning",
      "existenceCondition": {
        "field": "name",
        "equals": "myResourceGroup"
      },
      "resourceGroupName": "myResourceGroup",
      "deploymentScope": "subscription",
      "deployment": {
        "location": "canadacentral",
        "properties": {
          "mode": "incremental",
          "template": {
            "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
            "contentVersion": "1.0.0.0",
            "parameters": {},
            "variables": {},
            "resources": [
              {
                "name": "myResourceGroup",
                "type": "Microsoft.Resources/resourceGroups",
                "apiVersion": "2019-10-01",
                "location": "canadacentral"
              }
            ],
            "outputs": {}
          }
        }
      }
    }
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文