问题
I am trying to enable diagnostics for an azure datafactory using an ARM Template after is has been created via a c# automation application. I am attempting to use the steps here for the Non-Compute Resource Template:
https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-enable-diagnostic-logs-using-template
Step 2 of the above instructions state:
In the resources array of the resource for which you want to enable Diagnostic Logs, add a resource of type [resource namespace]/providers/diagnosticSettings.
Here are where my questions lie:
I was hoping that I could enable the diagnostics for a datafactory(or any resource really) outside of the resources array for for that resource since the data factory is not being created as part of the ARM template. Is that possible?
If so what is the [resource namespace] in the above quote? I have tried using "Microsoft.DataFactory/providers/diagnosticSettings", but that fails as an invalid resource.
Here is the JSON I have thus far(remember this is outside of the resource array for the data factory, because it is already created in an earlier step).
{
"type": "Microsoft.DataFactory/providers/diagnosticSettings",
"name": "[concat('Microsoft.Insights/', parameters('factoryName'))]",
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "[parameters('factoryName')]",
"workspaceId": "[parameters('workspaceId')]",
"logs": [
{
"category": "/* log category name */",
"enabled": true,
"retentionPolicy": {
"days": 0,
"enabled": false
}
}
],
"metrics": [
{
"category": "AllMetrics",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
回答1:
try this (This worked for me)
Let's think for example:
Deployment name: AzureADF-DiagSettings-Deployment
Deployment resource group: ADFactoryRG
Azure Data Factory instance name: ADFactory
Diagnostic settings name (In ADFactory): DiagService
Log analytics instance name: OMSWorkspace
Log analytics resource group: OMSWorkspaceRG
{
"$schema": "https://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2017-05-10",
"name": "AzureADF-DiagSettings-Deployment",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "ADFactoryRG",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "microsoft.datafactory/factories/providers/diagnosticsettings",
"name": "ADFactory/Microsoft.Insights/DiagService",
"apiVersion": "2017-05-01-preview",
"properties": {
"name": "DiagService",
"storageAccountId": null,
"eventHubAuthorizationRuleId": null,
"eventHubName": null,
"workspaceId": "OMSWorkspaceRG/Microsoft.OperationalInsights/workspaces/OMSWorkspace",
"logs": [
{
"category": "PipelineRuns",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "TriggerRuns",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
},
{
"category": "ActivityRuns",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
],
"metrics": [
{
"category": "AllMetrics",
"timeGrain": "PT1M",
"enabled": true,
"retentionPolicy": {
"enabled": false,
"days": 0
}
}
]
}
}
],
"outputs": {}
},
"parameters": {}
}
}
],
"outputs": {}
}
来源:https://stackoverflow.com/questions/52975611/how-to-enable-diagnostics-in-an-azure-datafactory-after-creation