10 thoughts on “Finding Diagnostic Settings Configuration for Azure Resources”

Leave a comment...

  1. Is there a way to get a list of the Diag Settings for all Azure resources, or is it only possible to query one resource at a time?

    Thx

  2. Hello Jeff,
    Thanks for your comment.
    At the time of this writing, we cannot get the list of the Diag Settings for all Azure resources without querying one resource at time.
    As described in this article, I am filtering first the resources which have Diag enabled (and not all Azure resources), and then I am querying each Azure resource to get their Diag Settings.
    Hope this helps!

  3. can I get script only true or false in VM through Get-AzVMDiagnosticsExtension
    if Get-AzVMDiagnosticsExtension is present true or else false

  4. Hello Rudraraju,
    You can use the following command to get the status of the VM Diagnostics Extension.

    $diagVMSettings = Get-AzVMDiagnosticsExtension -VMName "VMName" -ResourceGroupName "ResourceGroupName"
    if ($diagVMSettings) {
    Write-Output "True is present"
    }
    else {
    Write-Output "False is NOT enabled"
    }

    Hope this helps!
    -Charbel

  5. Hi Charbel,

    Did Microsoft break this? I am getting no output and receiving this error when running the script:

    “WARNING: 4:06:16 PM – The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases.
    WARNING: 4:06:16 PM – The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes.”

    It seems the “Get-AzDiagnosticSetting” command might be broken. Please let me know if you see similar results. Thank you!

  6. Hello Frank, thanks for the comment!
    Please note that this is not an error message. As per the warning messages, these would be automatically removed when they are addressed in the future releases of Az.Monitor Azure PowerShell module.
    I am currently using the latest Az.Monitor version 3.0.0 of the module and Az version 7.2.0.
    I’ve just tried it from my side and it’s working as expected.
    Hope it helps!

  7. Hi Charbel,

    Using your script, I receive the following error msg below. I am using Az.Monitor ver. 3.0.0 & Az version 7.2.0:

    Get-AzDiagnosticSetting : Exception type: ErrorResponseException, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseException: Operation returned an
    invalid status code ‘BadRequest’ at Microsoft.Azure.Management.Monitor.DiagnosticSettingsOperations.d__8.MoveNext().

  8. Hello Ryan, thanks for the feedback!
    Could you please update the Az PowerShell module to version 8.0.0 and try again?
    I have updated the script.

  9. Hi Charbel, This is great. I would like to see what are resources not having Diagnostic Settings applied.

    You are filtering only those having DiagnosticSettings:
    $azDiagSettings = Get-AzDiagnosticSetting -ResourceId $resourceId `
    -WarningAction SilentlyContinue -ErrorAction SilentlyContinue | Where-Object {$_.Id -ne $NULL}

    Is there any way to list which are not enabled?

  10. Hello Sripada, thanks for your comment!
    Yes, this would be possible to export the list of resources that do NOT have Diagnostic Settings enabled and configured.
    Please check the following section and let me know if it works for you.
    Hope it helps!

Let us know what you think, or ask a question...