Bylaw

Gallery › Portal › Azure built-in policies

Shared dashboards should not have markdown tiles with inline content

Uses Condition Policy Audit Deny Disabled Mode Indexed Version 1.1.0

Disallow creating a shared dashboard that has inline content in markdown tiles and enforce that the content should be stored as a markdown file that's hosted online. If you use inline content in the markdown tile, you cannot manage encryption of the content. By configuring your own storage, you can encrypt, double encrypt and even bring your own keys. Enabling this policy restricts users to use 2020-09-01-preview or above version of shared dashboards REST API.

ConvertTo-Bylaw converted this policy, and proved it compiles back to the same definition. Conditions the language can't express yet are written as raw JSON with Condition.

Azure Policy JSONSharedDashboardInlineContent_Deny.json · 123 lines
{
  "properties": {
    "displayName": "Shared dashboards should not have markdown tiles with inline content",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disallow creating a shared dashboard that has inline content in markdown tiles and enforce that the content should be stored as a markdown file that's hosted online. If you use inline content in the markdown tile, you cannot manage encryption of the content. By configuring your own storage, you can encrypt, double encrypt and even bring your own keys. Enabling this policy restricts users to use 2020-09-01-preview or above version of shared dashboards REST API.",
    "metadata": {
      "version": "1.1.0",
      "category": "Portal"
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Portal/dashboards"
          },
          {
            "anyOf": [
              {
                "not": {
                  "value": "[requestContext().apiVersion]",
                  "greaterOrEquals": "2020-09-01-alpha"
                }
              },
              {
                "count": {
                  "field": "Microsoft.Portal/dashboards/lenses[*].parts[*]",
                  "where": {
                    "allOf": [
                      {
                        "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.type",
                        "equals": "Extension/HubsExtension/PartType/MarkdownPart"
                      },
                      {
                        "anyOf": [
                          {
                            "allOf": [
                              {
                                "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings",
                                "exists": "true"
                              },
                              {
                                "anyOf": [
                                  {
                                    "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings.markdownUri",
                                    "exists": "false"
                                  },
                                  {
                                    "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings.markdownSource",
                                    "exists": "false"
                                  },
                                  {
                                    "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings.markdownSource",
                                    "equals": "1"
                                  }
                                ]
                              }
                            ]
                          },
                          {
                            "allOf": [
                              {
                                "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings",
                                "exists": "false"
                              },
                              {
                                "anyOf": [
                                  {
                                    "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.markdownUri",
                                    "exists": "false"
                                  },
                                  {
                                    "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.markdownSource",
                                    "exists": "false"
                                  },
                                  {
                                    "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.markdownSource",
                                    "equals": "1"
                                  }
                                ]
                              }
                            ]
                          }
                        ]
                      }
                    ]
                  }
                },
                "greater": 0
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/04c655fe-0ac7-48ae-9a32-3a2e208c7624",
  "name": "04c655fe-0ac7-48ae-9a32-3a2e208c7624"
}
Bylaw04c655fe-0ac7-48ae-9a32-3a2e208c7624.bylaw.ps1 · 33 lines
# Converted from SharedDashboardInlineContent_Deny.json by ConvertTo-Bylaw.
Policy '04c655fe-0ac7-48ae-9a32-3a2e208c7624' {

    Properties @{
        DisplayName   = 'Shared dashboards should not have markdown tiles with inline content'
        Description   = 'Disallow creating a shared dashboard that has inline content in markdown tiles and enforce that the content should be stored as a markdown file that''s hosted online. If you use inline content in the markdown tile, you cannot manage encryption of the content. By configuring your own storage, you can encrypt, double encrypt and even bring your own keys. Enabling this policy restricts users to use 2020-09-01-preview or above version of shared dashboards REST API.'
        Version       = '1.1.0'
        Category      = 'Portal'
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.Portal/dashboards' {

        Require 'Requirement 1' {
            Condition -Violation '{ "not": { "value": "[requestContext().apiVersion]", "greaterOrEquals": "2020-09-01-alpha" } }'
        }

        Require 'lenses.parts, lenses.parts.metadata.type, lenses.parts.metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings and 4 more are as required' {
            Condition -Violation '{ "count": { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*]", "where": { "allOf": [ { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.type", "equals": "Extension/HubsExtension/PartType/MarkdownPart" }, { "anyOf": [ { "allOf": [ { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings", "exists": true }, { "anyOf": [ { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings.markdownUri", "exists": false }, { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings.markdownSource", "exists": false }, { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings.markdownSource", "equals": "1" } ] } ] }, { "allOf": [ { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.settings", "exists": false }, { "anyOf": [ { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.markdownUri", "exists": false }, { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.markdownSource", "exists": false }, { "field": "Microsoft.Portal/dashboards/lenses[*].parts[*].metadata.Extension-HubsExtension-PartType-MarkdownPart.settings.content.markdownSource", "equals": "1" } ] } ] } ] } ] } }, "greater": 0 }'
        }
    }

    Effect (Param Effect)
}

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