Deploy Diagnostic Settings for Storage Analytics to Event Hub.

{
“properties”: {
“displayName”: “Deploy Diagnostic Settings for Storage Analytics to Event Hub”,
“policyType”: “Custom”,
“mode”: “Indexed”,
“metadata”: {
“createdBy”: “9e1a4c2c-4a14-468c-bad0-0ed38afbb990”,
“createdOn”: “2023-01-17T02:48:32.7901427Z”,
“updatedBy”: null,
“updatedOn”: null,
“category”: “Storage”
},
“parameters”: {
“eventHubRuleId”: {
“type”: “String”,
“metadata”: {
“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”: {
“type”: “String”,
“metadata”: {
“displayName”: “Event Hub name”,
“assignPermissions”: true
}
},
“eventHubLocation”: {
“type”: “String”,
“metadata”: {
“displayName”: “Event Hub Location”,
“description”: “The location the Event Hub resides in. Only Logic Apps in this location will be linked to this Event Hub.”,
“strongType”: “location”
},
“defaultValue”: “”
},
“servicesToDeploy”: {
“type”: “Array”,
“metadata”: {
“displayName”: “Storage services to deploy”,
“description”: “List of Storage services to deploy”
},
“allowedValues”: [
“storageAccounts”,
“blobServices”,
“fileServices”,
“tableServices”,
“queueServices”
],
“defaultValue”: [
“storageAccounts”,
“blobServices”,
“fileServices”,
“tableServices”,
“queueServices”
]
},
“diagnosticsSettingNameToUse”: {
“type”: “String”,
“metadata”: {
“displayName”: “Setting name”,
“description”: “Name of the diagnostic settings.”
},
“defaultValue”: “storageAccountsDiagnosticsLogsToEventHub”
},
“effect”: {
“type”: “String”,
“metadata”: {
“displayName”: “Effect”,
“description”: “Enable or disable the execution of the policy”
},
“allowedValues”: [
“DeployIfNotExists”,
“Disabled”
],
“defaultValue”: “DeployIfNotExists”
},
“StorageDelete”: {
“type”: “String”,
“metadata”: {
“displayName”: “StorageDelete – Enabled”,
“description”: “Whether to stream StorageDelete logs to the Log Analytics workspace – True or False”
},
“allowedValues”: [
“True”,
“False”
],
“defaultValue”: “True”
},
“StorageWrite”: {
“type”: “String”,
“metadata”: {
“displayName”: “StorageWrite – Enabled”,
“description”: “Whether to stream StorageWrite logs to the Log Analytics workspace – True or False”
},
“allowedValues”: [
“True”,
“False”
],
“defaultValue”: “True”
},
“StorageRead”: {
“type”: “String”,
“metadata”: {
“displayName”: “StorageRead – Enabled”,
“description”: “Whether to stream StorageRead logs to the Log Analytics workspace – True or False”
},
“allowedValues”: [
“True”,
“False”
],
“defaultValue”: “True”
},
“Transaction”: {
“type”: “String”,
“metadata”: {
“displayName”: “Transaction – Enabled”,
“description”: “Whether to stream Transaction logs to the Log Analytics workspace – True or False”
},
“allowedValues”: [
“True”,
“False”
],
“defaultValue”: “True”
}
},
“policyRule”: {
“if”: {
“allOf”: [
{
“field”: “type”,
“equals”: “Microsoft.Storage/storageAccounts”
},
{
“anyOf”: [
{
“value”: “[parameters(‘eventHubLocation’)]”,
“equals”: “”
},
{
“field”: “location”,
“equals”: “[parameters(‘eventHubLocation’)]”
}
]
}
]
},
“then”: {
“effect”: “[parameters(‘effect’)]”,
“details”: {
“type”: “Microsoft.Insights/diagnosticSettings”,
“roleDefinitionIds”: [
“/providers/Microsoft.Authorization/roleDefinitions/749f88d5-cbae-40b8-bcfc-e573ddc772fa”,
“/providers/Microsoft.Authorization/roleDefinitions/f526a384-b230-433a-b45c-95f59c4a2dec”,
“/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c”
],
“existenceCondition”: {
“allOf”: [
{
“count”: {
“field”: “Microsoft.Insights/diagnosticSettings/metrics[*]”,
“where”: {
“allOf”: [
{
“field”: “Microsoft.Insights/diagnosticSettings/metrics[*].category”,
“equals”: “Transaction”
},
{
“field”: “Microsoft.Insights/diagnosticSettings/metrics[*].enabled”,
“equals”: “True”
}
]
}
},
“greater”: 0
},
{
“field”: “Microsoft.Insights/diagnosticSettings/logs.enabled”,
“contains”: “true”
},
{
“field”: “Microsoft.Insights/diagnosticSettings/eventHubAuthorizationRuleId”,
“equals”: “[parameters(‘eventHubRuleId’)]”
}
]
},
“deployment”: {
“properties”: {
“mode”: “incremental”,
“template”: {
“$schema”: “http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#”,
“contentVersion”: “1.0.0.0”,
“parameters”: {
“servicesToDeploy”: {
“type”: “array”
},
“diagnosticsSettingNameToUse”: {
“type”: “string”
},
“resourceName”: {
“type”: “string”
},
“eventHubRuleId”: {
“type”: “string”
},
“eventHubName”: {
“type”: “string”
},
“location”: {
“type”: “string”
},
“Transaction”: {
“type”: “string”
},
“StorageRead”: {
“type”: “string”
},
“StorageWrite”: {
“type”: “string”
},
“StorageDelete”: {
“type”: “string”
}
},
“variables”: {},
“resources”: [
{
“condition”: “[contains(parameters(‘servicesToDeploy’), ‘blobServices’)]”,
“type”: “Microsoft.Storage/storageAccounts/blobServices/providers/diagnosticSettings”,
“apiVersion”: “2017-05-01-preview”,
“name”: “[concat(parameters(‘resourceName’), ‘/default/’, ‘Microsoft.Insights/’, parameters(‘diagnosticsSettingNameToUse’))]”,
“location”: “[parameters(‘location’)]”,
“dependsOn”: [],
“properties”: {
“eventHubAuthorizationRuleId”: “[parameters(‘eventHubRuleId’)]”,
“eventHubName”: “[parameters(‘eventHubName’)]”,
“metrics”: [
{
“category”: “Transaction”,
“enabled”: “[parameters(‘Transaction’)]”,
“retentionPolicy”: {
“days”: 0,
“enabled”: false
},
“timeGrain”: null
}
],
“logs”: [
{
“category”: “StorageRead”,
“enabled”: “[parameters(‘StorageRead’)]”
},
{
“category”: “StorageWrite”,
“enabled”: “[parameters(‘StorageWrite’)]”
},
{
“category”: “StorageDelete”,
“enabled”: “[parameters(‘StorageDelete’)]”
}
]
}
},
{
“condition”: “[contains(parameters(‘servicesToDeploy’), ‘fileServices’)]”,
“type”: “Microsoft.Storage/storageAccounts/fileServices/providers/diagnosticSettings”,
“apiVersion”: “2017-05-01-preview”,
“name”: “[concat(parameters(‘resourceName’), ‘/default/’, ‘Microsoft.Insights/’, parameters(‘diagnosticsSettingNameToUse’))]”,
“location”: “[parameters(‘location’)]”,
“dependsOn”: [],
“properties”: {
“eventHubAuthorizationRuleId”: “[parameters(‘eventHubRuleId’)]”,
“eventHubName”: “[parameters(‘eventHubName’)]”,
“metrics”: [
{
“category”: “Transaction”,
“enabled”: “[parameters(‘Transaction’)]”,
“retentionPolicy”: {
“days”: 0,
“enabled”: false
},
“timeGrain”: null
}
],
“logs”: [
{
“category”: “StorageRead”,
“enabled”: “[parameters(‘StorageRead’)]”
},
{
“category”: “StorageWrite”,
“enabled”: “[parameters(‘StorageWrite’)]”
},
{
“category”: “StorageDelete”,
“enabled”: “[parameters(‘StorageDelete’)]”
}
]
}
},
{
“condition”: “[contains(parameters(‘servicesToDeploy’), ‘tableServices’)]”,
“type”: “Microsoft.Storage/storageAccounts/tableServices/providers/diagnosticSettings”,
“apiVersion”: “2017-05-01-preview”,
“name”: “[concat(parameters(‘resourceName’), ‘/default/’, ‘Microsoft.Insights/’, parameters(‘diagnosticsSettingNameToUse’))]”,
“location”: “[parameters(‘location’)]”,
“dependsOn”: [],
“properties”: {
“eventHubAuthorizationRuleId”: “[parameters(‘eventHubRuleId’)]”,
“eventHubName”: “[parameters(‘eventHubName’)]”,
“metrics”: [
{
“category”: “Transaction”,
“enabled”: “[parameters(‘Transaction’)]”,
“retentionPolicy”: {
“days”: 0,
“enabled”: false
},
“timeGrain”: null
}
],
“logs”: [
{
“category”: “StorageRead”,
“enabled”: “[parameters(‘StorageRead’)]”
},
{
“category”: “StorageWrite”,
“enabled”: “[parameters(‘StorageWrite’)]”
},
{
“category”: “StorageDelete”,
“enabled”: “[parameters(‘StorageDelete’)]”
}
]
}
},
{
“condition”: “[contains(parameters(‘servicesToDeploy’), ‘queueServices’)]”,
“type”: “Microsoft.Storage/storageAccounts/queueServices/providers/diagnosticSettings”,
“apiVersion”: “2017-05-01-preview”,
“name”: “[concat(parameters(‘resourceName’), ‘/default/’, ‘Microsoft.Insights/’, parameters(‘diagnosticsSettingNameToUse’))]”,
“location”: “[parameters(‘location’)]”,
“dependsOn”: [],
“properties”: {
“eventHubAuthorizationRuleId”: “[parameters(‘eventHubRuleId’)]”,
“eventHubName”: “[parameters(‘eventHubName’)]”,
“metrics”: [
{
“category”: “Transaction”,
“enabled”: “[parameters(‘Transaction’)]”,
“retentionPolicy”: {
“days”: 0,
“enabled”: false
},
“timeGrain”: null
}
],
“logs”: [
{
“category”: “StorageRead”,
“enabled”: “[parameters(‘StorageRead’)]”
},
{
“category”: “StorageWrite”,
“enabled”: “[parameters(‘StorageWrite’)]”
},
{
“category”: “StorageDelete”,
“enabled”: “[parameters(‘StorageDelete’)]”
}
]
}
},
{
“condition”: “[contains(parameters(‘servicesToDeploy’), ‘storageAccounts’)]”,
“type”: “Microsoft.Storage/storageAccounts/providers/diagnosticSettings”,
“apiVersion”: “2017-05-01-preview”,
“name”: “[concat(parameters(‘resourceName’), ‘/’, ‘Microsoft.Insights/’, parameters(‘diagnosticsSettingNameToUse’))]”,
“location”: “[parameters(‘location’)]”,
“dependsOn”: [],
“properties”: {
“eventHubAuthorizationRuleId”: “[parameters(‘eventHubRuleId’)]”,
“eventHubName”: “[parameters(‘eventHubName’)]”,
“metrics”: [
{
“category”: “Transaction”,
“enabled”: “[parameters(‘Transaction’)]”,
“retentionPolicy”: {
“days”: 0,
“enabled”: false
},
“timeGrain”: null
}
]
}
}
],
“outputs”: {}
},
“parameters”: {
“diagnosticsSettingNameToUse”: {
“value”: “[parameters(‘diagnosticsSettingNameToUse’)]”
},
“eventHubRuleId”: {
“value”: “[parameters(‘eventHubRuleId’)]”
},
“eventHubName”: {
“value”: “[parameters(‘eventHubName’)]”
},
“location”: {
“value”: “[field(‘location’)]”
},
“resourceName”: {
“value”: “[field(‘name’)]”
},
“Transaction”: {
“value”: “[parameters(‘Transaction’)]”
},
“StorageDelete”: {
“value”: “[parameters(‘StorageDelete’)]”
},
“StorageWrite”: {
“value”: “[parameters(‘StorageWrite’)]”
},
“StorageRead”: {
“value”: “[parameters(‘StorageRead’)]”
},
“servicesToDeploy”: {
“value”: “[parameters(‘servicesToDeploy’)]”
}
}
}
}
}
}
}
},
“id”: “/subscriptions/6cae13a3-4be0-48e0-9466-d9f2f0f33bc9/providers/Microsoft.Authorization/policyDefinitions/9ecfc4b5-5444-4c6e-832e-c06ac3ef2ecc”,
“type”: “Microsoft.Authorization/policyDefinitions”,
“name”: “9ecfc4b5-5444-4c6e-832e-c06ac3ef2ecc”,
“systemData”: {
“createdBy”: “ganesh.sekarbabu@autodesk.com”,
“createdByType”: “User”,
“createdAt”: “2023-01-17T02:48:32.7728818Z”,
“lastModifiedBy”: “ganesh.sekarbabu@autodesk.com”,
“lastModifiedByType”: “User”,
“lastModifiedAt”: “2023-01-17T02:48:32.7728818Z”
}
}
Advertisement
This entry was posted in Azure, Azure event hub, Azure policy, Cloud and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s