Bylaw

Gallery › Key Vault › Azure built-in policies

Secrets should have content type set

Doesn't convert yet Policy Audit Deny Disabled Mode Microsoft.KeyVault.Data Version 1.0.1

A content type tag helps identify whether a secret is a password, connection string, etc. Different secrets have different rotation requirements. Content type tag should be set on secrets.

ConvertTo-Bylaw can't convert this policy yet:

Azure Policy JSONSecrets_ContentTypeSet.json · 50 lines
{
  "properties": {
    "displayName": "Secrets should have content type set",
    "policyType": "BuiltIn",
    "mode": "Microsoft.KeyVault.Data",
    "description": "A content type tag helps identify whether a secret is a password, connection string, etc. Different secrets have different rotation requirements. Content type tag should be set on secrets.",
    "metadata": {
      "version": "1.0.1",
      "category": "Key Vault"
    },
    "version": "1.0.1",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "'Audit' allows a non-compliant resource to be created, but flags it as non-compliant. 'Deny' blocks the resource creation. 'Disable' turns off the policy."
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.KeyVault.Data/vaults/secrets"
          },
          {
            "field": "Microsoft.KeyVault.Data/vaults/secrets/contentType",
            "exists": false
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/75262d3e-ba4a-4f43-85f8-9f72c090e5e3",
  "name": "75262d3e-ba4a-4f43-85f8-9f72c090e5e3"
}

Source: built-in-policies/policyDefinitions/Key Vault/Secrets_ContentTypeSet.json in Azure/azure-policy, under the MIT licence.