arrays - 设置 Azure 位置策略限制
问题描述
我想定义一个 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" ],
}
}
}
}
解决方案
Azure 策略具有定义和分配的概念。您提供的 JSON 符合定义的格式。
要使策略生效,您需要将定义分配给您希望策略应用的订阅。
您尝试应用的策略也可作为内置定义使用。您可以使用 Azure 门户直接分配此定义。
https://portal.azure.com/#blade/Microsoft_Azure_Policy/PolicyMenuBlade/Definitions
推荐阅读
- r - 使用 devtools 从 Github 上的公共仓库安装 R 包时出现 HTTP 404 错误
- python-3.x - 如何使用熊猫打开excel模板并将其保存到另一个路径
- android - 滚动到 Recycler View 问题的底部
- javascript - 使用 JavaScript 的 with(){} 语句时,无效变量会去哪里?
- excel - VBA 查找最后一行
- angular - 如何使 mat-checkbox 像单选按钮
- arrays - React Native - 具有对象数组的动态表单和更新状态
- mongodb - Golang官方MongoDB驱动ObjectID怪异行为
- css - 同一类的CSS级联元素但悬停一个
- sql - 如何在 DolphinDB 中加载指定的文本文件列?