Bylaw

Gallery › Storage › Azure built-in policies

Modify - Configure Azure File Sync to disable public network access

Converted Policy Disabled Modify Mode Indexed Version 1.0.0

The Azure File Sync's internet-accessible public endpoint are disabled by your organizational policy. You may still access the Storage Sync Service via its private endpoint(s).

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

Azure Policy JSONStorageSync_IncomingTrafficPolicy_Modify.json · 63 lines
{
  "properties": {
    "displayName": "Modify - Configure Azure File Sync to disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "The Azure File Sync's internet-accessible public endpoint are disabled by your organizational policy. You may still access the Storage Sync Service via its private endpoint(s).",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "defaultValue": "Modify"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.StorageSync/storageSyncServices"
          },
          {
            "field": "Microsoft.StorageSync/storageSyncServices/incomingTrafficPolicy",
            "notEquals": "AllowVirtualNetworksOnly"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "conflictEffect": "Audit",
          "operations": [
            {
              "condition": "[greater(requestContext().apiVersion, '2019-10-01')]",
              "operation": "addOrReplace",
              "field": "Microsoft.StorageSync/storageSyncServices/incomingTrafficPolicy",
              "value": "AllowVirtualNetworksOnly"
            }
          ]
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/0e07b2e9-6cd9-4c40-9ccb-52817b95133b",
  "name": "0e07b2e9-6cd9-4c40-9ccb-52817b95133b"
}
Bylaw0e07b2e9-6cd9-4c40-9ccb-52817b95133b.bylaw.ps1 · 30 lines
# Converted from StorageSync_IncomingTrafficPolicy_Modify.json by ConvertTo-Bylaw.
Policy '0e07b2e9-6cd9-4c40-9ccb-52817b95133b' {

    Properties @{
        DisplayName   = 'Modify - Configure Azure File Sync to disable public network access'
        Description   = 'The Azure File Sync''s internet-accessible public endpoint are disabled by your organizational policy. You may still access the Storage Sync Service via its private endpoint(s).'
        Version       = '1.0.0'
        Category      = 'Storage'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.StorageSync/storageSyncServices' {

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

    Modify -Role 'Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field incomingTrafficPolicy | AddOrReplace 'AllowVirtualNetworksOnly' -Condition (Arm '[greater(requestContext().apiVersion, ''2019-10-01'')]')
    }
}

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