JSON
Copy definition Copy definition 4 EPAC EPAC
{ 6 items displayName: "Deploy Diagnostic Settings for Database for PostgreSQL to Event Hub" , description: "Deploys the diagnostic settings for Database for PostgreSQL to stream to a Event Hub when any Database for PostgreSQL which is missing this diagnostic settings is created or updated. The policy will set the diagnostic with all metrics and category enabled." , metadata: { 2 items version: "1.0.0" , category: "Monitoring" } , mode: "Indexed" , parameters: { 7 items eventHubRuleId: { 2 items type: "String" , metadata: { 4 items displayName: "Event Hub Authorization Rule Id" , description: "The Event Hub authorization rule Id for Azure Diagnostics. The authorization rule needs to be at Event Hub namespace level. e.g. /subscriptions/{subscription Id}/resourceGroups/{resource group}/providers/Microsoft.EventHub/namespaces/{Event Hub namespace}/authorizationrules/{authorization rule}" , strongType: "Microsoft.EventHub/Namespaces/AuthorizationRules" , assignPermissions: true } } , eventHubName: { 2 items type: "String" , metadata: { 2 items displayName: "Event Hub Name" , description: "Specify the name of the Event Hub" } } , effect: { 4 items type: "String" , metadata: { 2 items displayName: "Effect" , description: "Enable or disable the execution of the policy" } , allowedValues: [ 3 items "DeployIfNotExists" , "AuditIfNotExists" , "Disabled" ] , defaultValue: "DeployIfNotExists" } , profileName: { 3 items type: "String" , metadata: { 2 items displayName: "Profile name" , description: "The diagnostic settings profile name" } , defaultValue: "setbypolicy_EH" } , metricsEnabled: { 4 items } , logsEnabled: { 4 items } , eventHubLocation: { 4 items type: "String" , metadata: { 3 items displayName: "Event Hub Location" , description: "Resource Location must be in the same location as the Event Hub Namespace." , strongType: "location" } , allowedValues: [ 2 items "swedencentral" , "westeurope" ] , defaultValue: "westeurope" } } , policyRule: { 2 items if: { 1 item } , then: { 2 items effect: "[parameters('effect')]" , details: { 5 items type: "Microsoft.Insights/diagnosticSettings" , name: "[parameters('profileName')]" , existenceCondition: { 1 item allOf: [ 4 items { 2 items count: { 2 items field: "Microsoft.Insights/diagnosticSettings/logs[*]" , where: { 1 item allOf: [ 2 items { 2 items field: "Microsoft.Insights/diagnosticSettings/logs[*].enabled" , equals: "[parameters('logsEnabled')]" } , { 2 items field: "microsoft.insights/diagnosticSettings/logs[*].categoryGroup" , equals: "allLogs" } ] } } , equals: 1 } , { 2 items field: "Microsoft.Insights/diagnosticSettings/metrics.enabled" , equals: "[parameters('metricsEnabled')]" } , { 2 items field: "Microsoft.Insights/diagnosticSettings/eventHubAuthorizationRuleId" , matchInsensitively: "[parameters('eventHubRuleId')]" } , { 2 items field: "Microsoft.Insights/diagnosticSettings/eventHubName" , matchInsensitively: "[parameters('eventHubName')]" } ] } , roleDefinitionIds: [ 2 items ] , deployment: { 1 item properties: { 3 items mode: "Incremental" , template: { 6 items $schema: "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#" , contentVersion: "1.0.0.0" , parameters: { 7 items } , variables : {} , resources: [ 1 item { 6 items type: "Microsoft.DBforPostgreSQL/servers/providers/diagnosticSettings" , apiVersion: "2021-05-01-preview" , name: 🔍 "[
concat(
parameters('resourceName'),
'/',
'Microsoft.Insights/',
parameters('profileName')
)
]", location: "[parameters('location')]" , dependsOn : [] , properties: { 4 items eventHubAuthorizationRuleId: "[parameters('eventHubRuleId')]" , eventHubName: "[parameters('eventHubName')]" , metrics: [ 1 item ] , logs: [ 1 item { 2 items categoryGroup: "allLogs" , enabled: "[parameters('logsEnabled')]" } ] } } ] , outputs: { 1 item policy: { 2 items type: "string" , value: 🔍 "[
concat(
'Diagnostic setting',
parameters('profileName'),
'for type Database for PostgreSQL (
Microsoft.DBforPostgreSQL/servers
),
resourceName',
parameters('resourceName'),
'to EventHub',
parameters('eventHubRuleId'),
':',
parameters('eventHubName'),
'configured'
)
]" } } } , parameters: { 7 items } } } } } } }