Reputation: 2155
I want to get ahold of the diagnostic settings for all network security groups. I was hoping the powershell cmdlet Find-AzureRmResource would work, but it seems like you can't search for sub-resources on sub-providers without specifying the parent resource.
I would have hoped something like this would work:
Find-AzureRmResource -ResourceType Microsoft.Network/networkSecurityGroups -ExtensionResourceType Microsoft.Insights/diagnosticSettings
However, this just returns the network security groups, and I think it is completely ignoring the ExtensionResourceType parameter. Here is an example of a resource ID for the diagnostic settings on an NSG:
/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkSecurityGroups/{nsg-name}/providers/microsoft.insights/diagnosticSettings/service
I noticed that the Find-AzureRmResource cmdlet has an -ODataQuery parameter, so I wonder if I could get it to work if I knew what to pass to this parameter?
I did find that I can get the equivalent list like this, but it is really slow (when you have hundreds of NGSs) because it queries the diagnostic settings individually instead of returning them all in one shot:
Find-AzureRmResource -ResourceType Microsoft.Network/networkSecurityGroups | Get-AzureRmDiagnosticSetting
Upvotes: 0
Views: 696
Reputation: 992
There is no single API call to retrieve all the diagnostic settings on all NSGs. If you have all the ARM resource ids for all NSGs, you will need to make multiple calls to Get-AzureRmDiagnosticSetting.
Upvotes: 1