JSON
Copy definition Copy definition 4 EPAC EPAC
{ 6 items displayName: "Deploy Diagnostic Settings for Recovery Services vault to Event Hub" , description: "Deploys the diagnostic settings for Recovery Services vaults to stream to a Event Hub when any Recovery Services vaults which is missing this diagnostic settings is created or updated. The policy will set the diagnostic with all metrics and category enabled. Amended built-in policy to add eventHubName-parameter to stream to a specific event hub." , metadata: { 2 items version: "1.0.0" , category: "Monitoring" } , mode: "Indexed" , parameters: { 9 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" } , tagName: { 3 items type: "String" , metadata: { 2 items displayName: "Exclusion Tag Name" , description: "Name of the tag to use for excluding vaults from this policy. This should be used along with the Exclusion Tag Value parameter." } , defaultValue: "" } , tagValue: { 3 items type: "String" , metadata: { 2 items displayName: "Exclusion Tag Value" , description: "Value of the tag to use for excluding vaults from this policy. This should be used along with the Exclusion Tag Name parameter." } , defaultValue: "" } } , 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[*].Category" , in: [ 7 items "CoreAzureBackup" , "AddonAzureBackupJobs" , "AddonAzureBackupAlerts" , "AddonAzureBackupPolicy" , "AddonAzureBackupStorage" , "AddonAzureBackupProtectedInstance" , "AzureBackupReport" ] } , { 2 items field: "Microsoft.Insights/diagnosticSettings/logs[*].Enabled" , equals: "[parameters('logsEnabled')]" } ] } } , equals: 7 } , { 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.RecoveryServices/vaults/providers/diagnosticSettings" , apiVersion: "2021-05-01-preview" , name: 🔍 "[
concat(
parameters('resourceName'),
'/',
'Microsoft.Insights/',
parameters('profileName')
)
]", location: "[parameters('location')]" , dependsOn : [] , properties: { 4 items eventHubName: "[parameters('eventHubName')]" , eventHubAuthorizationRuleId: "[parameters('eventHubRuleId')]" , 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 Recover Services vaults (
Microsoft.RecoveryServices/vaults
),
resourceName',
parameters('resourceName'),
'to EventHub',
parameters('eventHubRuleId'),
':',
parameters('eventHubName'),
'configured'
)
]" } } } , parameters: { 7 items } } } } } } }