Gallery › SQL › Azure Community Policy
Deploy hybrid use for Azure SQL Elastic Pools
Converted Policy AuditIfNotExists DeployIfNotExists Disabled Mode All Version 1.0.0
This Policy will enable HUB for Azure SQL Elastic Pools.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 104 lines
{
"name": "2ee8d4f8-d152-4532-9f31-ab106dba8f12",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Deploy hybrid use for Azure SQL Elastic Pools",
"description": "This Policy will enable HUB for Azure SQL Elastic Pools.",
"metadata": {
"category": "SQL",
"version": "1.0.0"
},
"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": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Sql/servers/elasticPools"
},
{
"anyOf": [
{
"field": "Microsoft.Sql/servers/elasticpools/sku.tier",
"equals": "BusinessCritical"
},
{
"field": "Microsoft.Sql/servers/elasticpools/sku.tier",
"equals": "GeneralPurpose"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Sql/servers/elasticPools",
"name": "[field('fullname')]",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/8e3af657-a8ff-443c-a75c-2fe8c4bcb635"
],
"existenceCondition": {
"allOf": [
{
"field": "Microsoft.Sql/servers/elasticpools/licenseType",
"equals": "BasePrice"
}
]
},
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"sqlElasticPoolName": {
"type": "string"
},
"location": {
"type": "string"
}
},
"resources": [
{
"name": "[parameters('sqlElasticPoolName')]",
"type": "Microsoft.Sql/servers/elasticpools",
"apiVersion": "2017-10-01-preview",
"location": "[parameters('location')]",
"properties": {
"licenseType": "BasePrice"
}
}
]
},
"parameters": {
"sqlElasticPoolName": {
"value": "[field('fullname')]"
},
"location": {
"value": "[field('location')]"
}
}
}
}
}
}
}
}
}Bylaw2ee8d4f8-d152-4532-9f31-ab106dba8f12.bylaw.ps1 · 39 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '2ee8d4f8-d152-4532-9f31-ab106dba8f12' {
Properties @{
DisplayName = 'Deploy hybrid use for Azure SQL Elastic Pools'
Description = 'This Policy will enable HUB for Azure SQL Elastic Pools.'
Category = 'SQL'
Version = '1.0.0'
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/elasticPools' {
Require 'sku.tier is not BusinessCritical' {
Field sku.tier | Must -Not -Be 'BusinessCritical' -IfPresent
}
Require 'sku.tier is not GeneralPurpose' {
Field sku.tier | Must -Not -Be 'GeneralPurpose' -IfPresent
}
}
DeployIfNotExists 'Microsoft.Sql/servers/elasticPools' -Role 'Owner' -Name (Arm '[field(''fullname'')]') -Effect (Param Effect) {
Require 'licenseType is BasePrice' {
Field licenseType | Must -Be 'BasePrice'
}
Deployment -TemplateFile './templates/2ee8d4f8-d152-4532-9f31-ab106dba8f12.json' -Parameters ([ordered]@{
sqlElasticPoolName = (Arm '[field(''fullname'')]')
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/2ee8d4f8-d152-4532-9f31-ab106dba8f12.json
Source: policyDefinitions/SQL/deploy-hybrid-use-for-azure-sql-elastic-pools/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw