Bylaw

Gallery › App Service › Azure built-in policies

[Deprecated]: API apps should use an Azure file share for its content directory

Converted Policy Audit Disabled Mode Indexed Version 1.0.0-deprecated Deprecated

The content directory of an API app should be located on an Azure file share. To learn more about using Azure Files for hosting app service content refer to https://go.microsoft.com/fwlink/?linkid=2151594. We recommend all customers who are still using API Apps to implement the built-in policy called 'App Service apps should use an Azure file shares for its content directory', which is scoped to include API apps in addition to Web Apps.

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

Azure Policy JSONApiApp_StorageAccountRequired_Audit.json · 54 lines
{
  "properties": {
    "displayName": "[Deprecated]: API apps should use an Azure file share for its content directory",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "The content directory of an API app should be located on an Azure file share. To learn more about using Azure Files for hosting app service content refer to https://go.microsoft.com/fwlink/?linkid=2151594. We recommend all customers who are still using API Apps to implement the built-in policy called 'App Service apps should use an Azure file shares for its content directory', which is scoped to include API apps in addition to Web Apps.",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "App Service",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites"
          },
          {
            "field": "kind",
            "like": "*api"
          },
          {
            "field": "Microsoft.Web/sites/storageAccountRequired",
            "equals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/324c7761-08db-4474-9661-d1039abc92ee",
  "name": "324c7761-08db-4474-9661-d1039abc92ee"
}
Bylaw324c7761-08db-4474-9661-d1039abc92ee.bylaw.ps1 · 34 lines
# Converted from ApiApp_StorageAccountRequired_Audit.json by ConvertTo-Bylaw.
Policy '324c7761-08db-4474-9661-d1039abc92ee' {

    Properties @{
        DisplayName   = '[Deprecated]: API apps should use an Azure file share for its content directory'
        Description   = 'The content directory of an API app should be located on an Azure file share. To learn more about using Azure Files for hosting app service content refer to https://go.microsoft.com/fwlink/?linkid=2151594. We recommend all customers who are still using API Apps to implement the built-in policy called ''App Service apps should use an Azure file shares for its content directory'', which is scoped to include API apps in addition to Web Apps.'
        Version       = '1.0.0-deprecated'
        Category      = 'App Service'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Web/sites' {

        When {
            Field kind | Must -BeLike '*api'
        }

        Require 'storageAccountRequired is not true' {
            Field storageAccountRequired | Must -Not -Be 'true' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/App Service/ApiApp_StorageAccountRequired_Audit.json in Azure/azure-policy, under the MIT licence.