Bylaw

Gallery › Cosmos DB › Azure built-in policies

Enable Azure Cosmos DB throughput policy

Converted Initiative Version 1.0.0

Enable throughput control for Azure Cosmos DB resources in the specified scope (Management group, Subscription or resource group). Takes max throughput as parameter. Use this policy to help enforce throughput control via the resource provider.

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

Azure Policy JSONCosmos_Throughput.json · 59 lines
{
  "properties": {
    "displayName": "Enable Azure Cosmos DB throughput policy",
    "policyType": "BuiltIn",
    "description": "Enable throughput control for Azure Cosmos DB resources in the specified scope (Management group, Subscription or resource group). Takes max throughput as parameter. Use this policy to help enforce throughput control via the resource provider.",
    "metadata": {
      "version": "1.0.0",
      "category": "Cosmos DB"
    },
    "version": "1.0.0",
    "parameters": {
      "throughputMax": {
        "type": "Integer",
        "metadata": {
          "displayName": "Max RUs",
          "description": "The maximum throughput (RU/s) that can be assigned to a container via the Resource Provider during create or update."
        }
      },
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Policy Effect",
          "description": "The desired effect of the throughput limit policy. The key based metadata write access policy is always enforced."
        },
        "allowedValues": [
          "audit",
          "deny",
          "disabled"
        ],
        "defaultValue": "deny"
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionReferenceId": "Cosmos_MaxThroughput_Deny",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/0b7ef78e-a035-4f23-b9bd-aff122a1b1cf",
        "definitionVersion": "1.*.*",
        "parameters": {
          "throughputMax": {
            "value": "[parameters('throughputMax')]"
          },
          "effect": {
            "value": "[parameters('effect')]"
          }
        }
      },
      {
        "policyDefinitionReferenceId": "Cosmos_DisableMetadata_Append",
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/4750c32b-89c0-46af-bfcb-2e4541a818d5",
        "definitionVersion": "1.*.*"
      }
    ],
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policySetDefinitions/cb5e1e90-7c33-491c-a15b-24885c915752",
  "name": "cb5e1e90-7c33-491c-a15b-24885c915752"
}
Bylawcb5e1e90-7c33-491c-a15b-24885c915752.bylaw.ps1 · 39 lines
# Converted from Cosmos_Throughput.json by ConvertTo-Bylaw.
Initiative 'cb5e1e90-7c33-491c-a15b-24885c915752' {

    Properties @{
        DisplayName   = 'Enable Azure Cosmos DB throughput policy'
        Description   = 'Enable throughput control for Azure Cosmos DB resources in the specified scope (Management group, Subscription or resource group). Takes max throughput as parameter. Use this policy to help enforce throughput control via the resource provider.'
        Version       = '1.0.0'
        Category      = 'Cosmos DB'
        PolicyVersion = '1.0.0'
    }

    Parameter ThroughputMax @{
        Type        = 'Integer'
        DisplayName = 'Max RUs'
        Description = 'The maximum throughput (RU/s) that can be assigned to a container via the Resource Provider during create or update.'
    }
    Parameter Effect @{
        AllowedValues = @('audit', 'deny', 'disabled')
        Default       = 'deny'
        DisplayName   = 'Policy Effect'
        Description   = 'The desired effect of the throughput limit policy. The key based metadata write access policy is always enforced.'
    }

    PolicyDefinition @{
        Id          = '0b7ef78e-a035-4f23-b9bd-aff122a1b1cf'
        ReferenceId = 'Cosmos_MaxThroughput_Deny'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            throughputMax = (Param ThroughputMax)
            effect        = (Param Effect)
        }
    }

    PolicyDefinition @{
        Id          = '4750c32b-89c0-46af-bfcb-2e4541a818d5'
        ReferenceId = 'Cosmos_DisableMetadata_Append'
        Version     = '1.*.*'
    }
}

Members (2)

Source: built-in-policies/policySetDefinitions/Cosmos DB/Cosmos_Throughput.json in Azure/azure-policy, under the MIT licence.