Gallery › SQL › Azure Community Policy
deploy-tde-sql-databases
Converted Policy AuditIfNotExists DeployIfNotExists Disabled Mode All Version 1.0.0
need to add description
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 77 lines
{
"name": "a712aded-1a15-4ffd-8b3d-97dbc7b732f2",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "deploy-tde-sql-databases",
"description": "need to add description",
"metadata": {
"version": "1.0.0",
"category": "SQL"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"DeployIfNotExists",
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Sql/servers/databases"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Sql/servers/databases/transparentDataEncryption",
"name": "current",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/9b7fa17d-e63e-47b0-bb0a-15c516ac86ec"
],
"existenceCondition": {
"field": "Microsoft.Sql/transparentDataEncryption.status",
"equals": "Enabled"
},
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"fullDbName": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('fullDbName'), '/current')]",
"type": "Microsoft.Sql/servers/databases/transparentDataEncryption",
"apiVersion": "2014-04-01",
"properties": {
"status": "Enabled"
}
}
]
},
"parameters": {
"fullDbName": {
"value": "[field('fullName')]"
}
}
}
}
}
}
}
}
}Bylawa712aded-1a15-4ffd-8b3d-97dbc7b732f2.bylaw.ps1 · 29 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'a712aded-1a15-4ffd-8b3d-97dbc7b732f2' {
Properties @{
DisplayName = 'deploy-tde-sql-databases'
Description = 'need to add description'
Version = '1.0.0'
Category = 'SQL'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'AuditIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy'
}
Resource 'Microsoft.Sql/servers/databases'
DeployIfNotExists 'Microsoft.Sql/servers/databases/transparentDataEncryption' -Role 'SQL DB Contributor' -Name 'current' -Effect (Param Effect) {
Require 'transparentDataEncryption.status is Enabled' {
Field 'Microsoft.Sql/transparentDataEncryption.status' | Must -Be 'Enabled'
}
Deployment -TemplateFile './templates/a712aded-1a15-4ffd-8b3d-97dbc7b732f2.json' -Parameters ([ordered]@{
fullDbName = (Arm '[field(''fullName'')]')
})
}
}Its deployment templates are written beside it:
templates/a712aded-1a15-4ffd-8b3d-97dbc7b732f2.json
Source: policyDefinitions/SQL/deploy-tde-sql-databases/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw