Bylaw

Gallery › Storage › Azure built-in policies

Configure file share with Microsoft.FileShares to disable public network access

Converted Policy Disabled Modify Mode Indexed Version 1.0.0

The file share with Microsoft.FileShares internet-accessible public endpoint are disabled by your organizational policy. You may still access the file share via its private endpoint(s) or Service endpoint(s).

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

Azure Policy JSONFileShares_IncomingTrafficPolicy_Modify.json · 62 lines
{
  "properties": {
    "displayName": "Configure file share with Microsoft.FileShares to disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "The file share with Microsoft.FileShares internet-accessible public endpoint are disabled by your organizational policy. You may still access the file share via its private endpoint(s) or Service 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.FileShares/fileShares"
          },
          {
            "field": "Microsoft.FileShares/fileShares/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "conflictEffect": "Audit",
          "operations": [
            {
              "operation": "addOrReplace",
              "field": "Microsoft.FileShares/fileShares/publicNetworkAccess",
              "value": "Disabled"
            }
          ]
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/32395e13-9837-458f-936d-4b21b1e37694",
  "name": "32395e13-9837-458f-936d-4b21b1e37694"
}
Bylaw32395e13-9837-458f-936d-4b21b1e37694.bylaw.ps1 · 30 lines
# Converted from FileShares_IncomingTrafficPolicy_Modify.json by ConvertTo-Bylaw.
Policy '32395e13-9837-458f-936d-4b21b1e37694' {

    Properties @{
        DisplayName   = 'Configure file share with Microsoft.FileShares to disable public network access'
        Description   = 'The file share with Microsoft.FileShares internet-accessible public endpoint are disabled by your organizational policy. You may still access the file share via its private endpoint(s) or Service 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.FileShares/fileShares' {

        Require 'publicNetworkAccess is Disabled' {
            Field publicNetworkAccess | Must -Be 'Disabled'
        }
    }

    Modify -Role 'Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field publicNetworkAccess | AddOrReplace 'Disabled'
    }
}

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