azurepowershellazure-powershellazure-diagnostics

Cannot remove a diagnostic setting with Remove-AzDiagnosticSetting


I have an diagnostic setting on Database/Master and I am having some difficulty with deleting it in AzureCLI.

So I use

Remove-AzDiagnosticSetting -ResourceId "/subscriptions/xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/PainfulRG/providers/Microsoft.Sql/servers/testsqltoday/databases/db1" -Name Jason

and it comes back with a Status of OK.

I then look at the activity log within the diagnostic settings within Azure Portal and I see :

  "resourceId": "/subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/resourceGroups/PainfulRG/providers/Microsoft.Sql/servers/testsqltoday/databases/db1/providers/Microsoft.Insights/diagnosticSettings/Jason",
    "status": {
        "value": "Succeeded",
        "localizedValue": "Succeeded"
    },
    "subStatus": {
        "value": "OK",
        "localizedValue": "OK (HTTP Status Code: 200)"
    },

So it seems it was OK (200 status).

But when I go to the diagnostic settings and click on db1 - and then into diagnostic settings - the setting is still there.


Solution

  • You can use the below rest API to delete diagnostic settings

    https://learn.microsoft.com/en-us/rest/api/monitor/diagnostic-settings/delete