Gallery › SQL › Azure Community Policy
Deny SQL VM TempDB LocalSSD
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
Denies a SQL Server VM's TempDB from using Local SSD (D: Drive).
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 53 lines
{
"name": "b52abc9a-5995-4598-be12-7a60f4617dce",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Deny SQL VM TempDB LocalSSD",
"description": "Denies a SQL Server VM's TempDB from using Local SSD (D: Drive).",
"metadata": {
"version": "1.0.0",
"category": "SQL"
},
"mode": "All",
"parameters": {
"drive": {
"type": "String",
"metadata": {
"displayName": "Drive",
"description": "Selects the specific disk drive to deny. Normally, Local SSD is under the D: drive"
},
"defaultValue": "D:*"
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.SqlVirtualMachine/sqlVirtualMachines"
},
{
"field": "Microsoft.SqlVirtualMachine/sqlVirtualMachines/storageConfigurationSettings.sqlTempDbSettings.defaultFilePath",
"like": "[parameters('drive')]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawb52abc9a-5995-4598-be12-7a60f4617dce.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'b52abc9a-5995-4598-be12-7a60f4617dce' {
Properties @{
DisplayName = 'Deny SQL VM TempDB LocalSSD'
Description = 'Denies a SQL Server VM''s TempDB from using Local SSD (D: Drive).'
Version = '1.0.0'
Category = 'SQL'
Mode = 'All'
}
Parameter Drive @{
Default = 'D:*'
DisplayName = 'Drive'
Description = 'Selects the specific disk drive to deny. Normally, Local SSD is under the D: drive'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.SqlVirtualMachine/sqlVirtualMachines' {
Require 'storageConfigurationSettings.sqlTempDbSettings.defaultFilePath is not like the Drive parameter' {
Field storageConfigurationSettings.sqlTempDbSettings.defaultFilePath | Must -Not -BeLike (Param Drive) -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/SQL/deny-sql-vm-tempdb-localssd/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw