【问题标题】:Set Azure Location Policy Restriction设置 Azure 位置策略限制
【发布时间】:2018-05-15 15:49:50
【问题描述】:

我想定义一个 Azure 策略,其中只能在订阅级别对“美国西部”和美国东部进行部署。

我知道我正在尝试填充一系列位置,但我在某些地方出错了;

{
  "policyRule": {
    "if": {
      "not": {
        "field": "location",
        "in": "[parameters('allowedLocations')]"
      }
    },
    "then": {
      "effect": "deny"
    }
  },
  "parameters": {
    "allowedLocations": {
      "type": "Array",
      "metadata": {
        "description": "The list of allowed locations for resources.",
        "displayName": "Allowed locations",
        "strongType": "location",
        "value": [ "West US", "East US" ], 
      }
    }
  }
}

【问题讨论】:

    标签: arrays json azure azure-resource-manager azure-policy


    【解决方案1】:

    Azure 策略具有定义和分配的概念。您提供的 JSON 符合 定义 的格式。

    要使策略生效,您需要将您的定义分配到您希望策略应用的订阅。

    您尝试应用的策略也可作为内置定义使用。您可以使用 Azure 门户直接分配此定义。

    https://portal.azure.com/#blade/Microsoft_Azure_Policy/PolicyMenuBlade/Definitions

    【讨论】:

      【解决方案2】:

      在创建initiative 或策略定义时,指定definition location 很重要。

      请参阅article 了解更多信息。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-27
        • 1970-01-01
        • 2018-07-17
        • 2021-08-15
        相关资源
        最近更新 更多