Azure Lei Zhang的博客

weibo: LeiZhang的微博/QQ: 185165016/QQ群:319036205/邮箱:leizhang1984@outlook.com/TeL:139-161-22926

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  489 随笔 :: 0 文章 :: 417 评论 :: 70万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

  《Windows Azure Platform 系列文章目录

 

  我们可以自定义policy,来符合公司的IT策略。

  我们这里演示的场景是,增加一个自定义policy,需要用户在创建vnet,或者增加subnet的时候,需要开启service endpoint for Microsoft.Storage

  否则创建失败

 

复制代码
{
  "properties": {
    "displayName": "Subnets should have storage account service endpoint",
    "policyType": "Custom",
    "mode": "All",
    "description": "This policy denies the creation of a subnet without a storage account service endpoint.",
    "metadata": {
      "createdBy": "48b0b875-4ccd-4df1-aeb1-166db79d2864",
      "createdOn": "2022-12-14T14:33:16.373002Z",
      "updatedBy": "48b0b875-4ccd-4df1-aeb1-166db79d2864",
      "updatedOn": "2022-12-14T15:14:34.2548617Z"
    },
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny"
      },
      "excludedSubnets": {
        "type": "Array",
        "metadata": {
          "displayName": "Excluded Subnets",
          "description": "Array of subnet names that are excluded from this policy"
        },
        "defaultValue": [
          "GatewaySubnet",
          "AzureFirewallSubnet",
          "AzureFirewallManagementSubnet"
        ]
      }
    },
    "policyRule": {
      "if": {
        "anyOf": [
          {
            "allOf": [
              {
                "equals": "Microsoft.Network/virtualNetworks",
                "field": "type"
              },
              {
                "count": {
                  "field": "Microsoft.Network/virtualNetworks/subnets[*]",
                  "where": {
                    "allOf": [
                      {
                        "field": "Microsoft.Network/virtualNetworks/subnets[*].serviceEndpoints[*].service",
                        "notequals": "Microsoft.Storage"
                      },
                      {
                        "field": "Microsoft.Network/virtualNetworks/subnets[*].name",
                        "notIn": "[parameters('excludedSubnets')]"
                      }
                    ]
                  }
                },
                "notEquals": 0
              }
            ]
          },
          {
            "allOf": [
              {
                "field": "type",
                "equals": "Microsoft.Network/virtualNetworks/subnets"
              },
              {
                "field": "name",
                "notIn": "[parameters('excludedSubnets')]"
              },
              {
                "field": "Microsoft.Network/virtualNetworks/subnets/serviceEndpoints[*].service",
                "notequals": "Microsoft.Storage"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  },
  "id": "/subscriptions/c69f7dec-22a1-4f72-a0b1-07811a7ed54b/providers/Microsoft.Authorization/policyDefinitions/75845297-272d-4bc2-9095-57a575eee51b",
  "type": "Microsoft.Authorization/policyDefinitions",
  "name": "75845297-272d-4bc2-9095-57a575eee51b",
  "systemData": {
    "createdBy": "",
    "createdByType": "User",
    "createdAt": "2022-12-14T14:33:16.3529038Z",
    "lastModifiedBy": "",
    "lastModifiedByType": "User",
    "lastModifiedAt": "2022-12-14T15:14:34.2209666Z"
  }
}
复制代码

 

posted on   Lei Zhang的博客  阅读(34)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
· 【译】Visual Studio 中新的强大生产力特性
· 2025年我用 Compose 写了一个 Todo App
历史上的今天:
2017-12-26 Azure ARM (20) 将非托管磁盘虚拟机(Unmanage Disk),迁移成托管磁盘虚拟机(Manage Disk)
2016-12-26 Microsoft Azure News(6) Azure新F系列虚拟机
点击右上角即可分享
微信分享提示