Bylaw

Gallery › Storage › Azure built-in policies

Public network access should be disabled for Azure File Sync

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Disabling the public endpoint allows you to restrict access to your Storage Sync Service resource to requests destined to approved private endpoints on your organization's network. There is nothing inherently insecure about allowing requests to the public endpoint, however, you may wish to disable it to meet regulatory, legal, or organizational policy requirements. You can disable the public endpoint for a Storage Sync Service by setting the incomingTrafficPolicy of the resource to AllowVirtualNetworksOnly.

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

Azure Policy JSONStorageSync_IncomingTrafficPolicy_AuditDeny.json · 50 lines
{
  "properties": {
    "displayName": "Public network access should be disabled for Azure File Sync",
    "description": "Disabling the public endpoint allows you to restrict access to your Storage Sync Service resource to requests destined to approved private endpoints on your organization's network. There is nothing inherently insecure about allowing requests to the public endpoint, however, you may wish to disable it to meet regulatory, legal, or organizational policy requirements. You can disable the public endpoint for a Storage Sync Service by setting the incomingTrafficPolicy of the resource to AllowVirtualNetworksOnly.",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage"
    },
    "version": "1.0.0",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.StorageSync/storageSyncServices"
          },
          {
            "field": "Microsoft.StorageSync/storageSyncServices/incomingTrafficPolicy",
            "notEquals": "AllowVirtualNetworksOnly"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/21a8cd35-125e-4d13-b82d-2e19b7208bb7",
  "name": "21a8cd35-125e-4d13-b82d-2e19b7208bb7"
}
Bylaw21a8cd35-125e-4d13-b82d-2e19b7208bb7.bylaw.ps1 · 28 lines
# Converted from StorageSync_IncomingTrafficPolicy_AuditDeny.json by ConvertTo-Bylaw.
Policy '21a8cd35-125e-4d13-b82d-2e19b7208bb7' {

    Properties @{
        DisplayName   = 'Public network access should be disabled for Azure File Sync'
        Description   = 'Disabling the public endpoint allows you to restrict access to your Storage Sync Service resource to requests destined to approved private endpoints on your organization''s network. There is nothing inherently insecure about allowing requests to the public endpoint, however, you may wish to disable it to meet regulatory, legal, or organizational policy requirements. You can disable the public endpoint for a Storage Sync Service by setting the incomingTrafficPolicy of the resource to AllowVirtualNetworksOnly.'
        Version       = '1.0.0'
        Category      = 'Storage'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.StorageSync/storageSyncServices' {

        Require 'incomingTrafficPolicy is AllowVirtualNetworksOnly' {
            Field incomingTrafficPolicy | Must -Be 'AllowVirtualNetworksOnly'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Storage/StorageSync_IncomingTrafficPolicy_AuditDeny.json in Azure/azure-policy, under the MIT licence.