azure - Azure 策略中的存在条件?

标签 azure azure-policy

我目前正在尝试了解 Azure 政策。我想我已经了解了别名,但我无法理解在哪里可以找到 ExistenceCondition equals 字段的正确值

  1. 它与我们应用的 PolicyRule 有什么不同?
  2. 我应该让 ExistanceCondition 与 PolicyRule 保持几乎相同吗?

我应用的策略规则:

    "if":{
            "allOf":[
               {
                  "field":"type",
                  "equals":"Microsoft.Insights/metricalerts"
               },
               {
                  "field":"Microsoft.Insights/metricalerts/enabled",
                  "equals":"true"
               },
               {
                  "field":"Microsoft.Insights/metricalerts/actions[*]",
                  "less":"1"
               }
            ]
         }

最佳答案

ExistenceConditionpolicyRule在控制方向上是相反的。 在策略规则中,仅当条件为真时才继续。在 ExistenceCondition 中,仅当条件为 false 时才继续。在下面的 policyRule 示例中,您仅过滤 storageAccount,然后继续。仅当条件为 false (deleteRetentionPolicy.enabled ==false) 时才会进行部署,因此它会继续进行部署。所以一旦部署完成,它将是deleteRetentionPolicy.enabled ==true

    "policyRule": {
        "if": {
            "allOf": [
                {
                    "field": "type",
                    "equals": "Microsoft.Storage/storageAccounts"
                },
                {
                    "field": "kind",
                    "in": [
                        "Storage",
                        "StorageV2",
                        "BlobStorage",
                        "BlockBlobStorage"
                    ]
                }
            ]
        },
        "then": {
            "effect": "DeployIfNotExists",
            "details": {
                "type": "Microsoft.Storage/storageAccounts/blobServices",
                "existenceCondition": {
                    "field": "Microsoft.Storage/storageAccounts/blobServices/default.deleteRetentionPolicy.enabled",
                    "equals": true
                },

关于azure - Azure 策略中的存在条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58050717/

相关文章:

php - 使用 PHP 获取重复的 session_id

azure - 基于自定义逻辑同时处理 Azure Blob 存储中的多个文件

azure - 参数 "storage_connection_string"是必需的,但未找到定义

c# - 如何使用 Microsoft Graph api 从 azure Active Directory 获取所有用户属性

Azure函数: What is the best way for me to filter out logs from other Azure Function Apps in "Log Stream"?

用户注册后的Azure B2C回调: Basic credentials specified for 'PreUserWriteRestful' are invalid

Azure 策略创建一个deployifnotexists 策略

azure - 如何限制Azure中安全组的删除?

对资源组强制执行命名约定的 Azure 策略没有效果

azure - 使用 Azure 策略将角色分配给存储帐户