Bylaw

Gallery › Storage › Azure Community Policy

Ensure https traffic only for storage account

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Ensure https traffic only for storage account

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONazurepolicy.json · 61 lines
{
  "name": "2bebee6d-992e-47fb-82be-ca35e8c0bee2",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Ensure https traffic only for storage account",
    "description": "Ensure https traffic only for storage account",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts"
          },
          {
            "anyOf": [
              {
                "allOf": [
                  {
                    "value": "[requestContext().apiVersion]",
                    "less": "2019-04-01"
                  },
                  {
                    "field": "Microsoft.Storage/storageAccounts/supportsHttpsTrafficOnly",
                    "exists": "false"
                  }
                ]
              },
              {
                "field": "Microsoft.Storage/storageAccounts/supportsHttpsTrafficOnly",
                "equals": "false"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw2bebee6d-992e-47fb-82be-ca35e8c0bee2.bylaw.ps1 · 34 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '2bebee6d-992e-47fb-82be-ca35e8c0bee2' {

    Properties @{
        DisplayName = 'Ensure https traffic only for storage account'
        Description = 'Ensure https traffic only for storage account'
        Version     = '1.0.0'
        Category    = 'Storage'
        Mode        = 'All'
    }

    Parameter Effect @{
        AllowedValues = @('Deny', 'Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Deny, Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.Storage/storageAccounts' {

        Require 'supportsHttpsTrafficOnly is as required' {
            AnyOf {
                Arm '[requestContext().apiVersion]' | Must -BeGreaterOrEqual '2019-04-01'
                Field supportsHttpsTrafficOnly | Must -Exist
            }
        }

        Require 'supportsHttpsTrafficOnly is not false' {
            Field supportsHttpsTrafficOnly | Must -Not -Be 'false' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Storage/ensure-https-traffic-only-for-storage-account/azurepolicy.json in Azure/Community-Policy, under the MIT licence.