Bylaw

Gallery › Security Center › Azure built-in policies

[Deprecated]: Microsoft Defender for SQL status should be protected for Arc-enabled SQL Servers

Converted Policy Audit Disabled Mode Indexed Version 1.2.0-deprecated Deprecated

This policy is being deprecated because Microsoft Defender for Cloud now provides an updated recommendation that replaces the functionality previously delivered by this policy. The new recommendation offers improved accuracy and coverage for monitoring the protection status. You can use the updated recommendation here: https://aka.ms/NewStatusRecommendation. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.

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

Azure Policy JSONASC_ProtectDefenderForSQLOnArc_Audit.json · 68 lines
{
  "properties": {
    "displayName": "[Deprecated]: Microsoft Defender for SQL status should be protected for Arc-enabled SQL Servers",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy is being deprecated because Microsoft Defender for Cloud now provides an updated recommendation that replaces the functionality previously delivered by this policy. The new recommendation offers improved accuracy and coverage for monitoring the protection status. You can use the updated recommendation here: https://aka.ms/NewStatusRecommendation. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.",
    "metadata": {
      "version": "1.2.0-deprecated",
      "category": "Security Center",
      "deprecated": true
    },
    "version": "1.2.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.AzureArcData/sqlServerInstances"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.AzureArcData/sqlServerInstances/azureDefenderStatus",
                "Equals": "Not Protected"
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.AzureArcData/sqlServerInstances/azureDefenderStatus",
                    "notEquals": "Not Protected"
                  },
                  {
                    "value": "[field('Microsoft.AzureArcData/sqlServerInstances/azureDefenderStatusLastUpdated')]",
                    "less": "[addDays(utcNow(), -1)]"
                  }
                ]
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.2.0",
      "1.1.0",
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/938c4981-c2c9-4168-9cd6-972b8675f906",
  "name": "938c4981-c2c9-4168-9cd6-972b8675f906"
}
Bylaw938c4981-c2c9-4168-9cd6-972b8675f906.bylaw.ps1 · 37 lines
# Converted from ASC_ProtectDefenderForSQLOnArc_Audit.json by ConvertTo-Bylaw.
Policy '938c4981-c2c9-4168-9cd6-972b8675f906' {

    Properties @{
        DisplayName   = '[Deprecated]: Microsoft Defender for SQL status should be protected for Arc-enabled SQL Servers'
        Description   = 'This policy is being deprecated because Microsoft Defender for Cloud now provides an updated recommendation that replaces the functionality previously delivered by this policy. The new recommendation offers improved accuracy and coverage for monitoring the protection status. You can use the updated recommendation here: https://aka.ms/NewStatusRecommendation. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.'
        Version       = '1.2.0-deprecated'
        Category      = 'Security Center'
        Deprecated    = $true
        PolicyVersion = '1.2.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.AzureArcData/sqlServerInstances' {

        Require 'azureDefenderStatus is not Not Protected' {
            Field azureDefenderStatus | Must -Not -Be 'Not Protected' -IfPresent
        }

        Require 'azureDefenderStatus and azureDefenderStatusLastUpdated are as required' {
            AnyOf {
                Field azureDefenderStatus | Must -Be 'Not Protected'
                Arm '[field(''Microsoft.AzureArcData/sqlServerInstances/azureDefenderStatusLastUpdated'')]' | Must -BeGreaterOrEqual (Arm '[addDays(utcNow(), -1)]')
            }
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Security Center/ASC_ProtectDefenderForSQLOnArc_Audit.json in Azure/azure-policy, under the MIT licence.