简体   繁体   中英

Add diagnostic log settings to Azure Data Factory via scripting/ARM templates

Following on a question posted a few days ago, Data factory Diagnostic settings , is there any way to accomplish adding to log analytics diagnostics via a script.

I could not find anything in Azure CLI - Data Factory Extension or Terraform Azure Data Factory provider to support this.

Diagnostics is not a property of a resource, but instead it is configured using it's own provider.

https://docs.microsoft.com/en-us/azure/azure-monitor/samples/resource-manager-diagnostic-settings

I did find answer to this question. Hopefully it will help anybody else looking for automation for Azure Data Factory.

The solution was not in documentation for Azure Data Factory, where I was looking, but in the scripting for - Azure Monitor. The link is - Create diagnostic settings to send platform logs and metrics to different destinations - Azure Monitor | Microsoft Docs

To the credit of the Azure team, this link is available on Portal where diagnostics is added to the Azure Data Factory, but the information about the Azure CLI is close to the bottom of the page. (So, egg on my face, for missing it.)

Here is the script that I came up with:

az monitor diagnostic-settings create  \
--name LogAnalytics02-Diagnostics \
--resource /subscriptions/(your-subscription)/resourceGroups/(your-resource-group)/providers/Microsoft.DataFactory/factories/(data-factory-name) \
--logs '[{"category": "PipelineRuns","enabled": true}]' \
--metrics '[{"category": "AllMetrics","enabled": true}]' \
--workspace /subscriptions/(your-subscription)/resourcegroups/(your-resource-group)/providers/microsoft.operationalinsights/workspaces/(your-log-analytics-workspace-name)

The pre-requisite to running the script is provisioning to the Azure Data Factory and the Log Analytics Workspace. Substitute the values to match the Azure subscription and resources.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM