Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.86k forks source link

Search-AzGraph adding a duplicate ResourceId property to the object returned #15730

Open kwill-MSFT opened 3 years ago

kwill-MSFT commented 3 years ago

Description

If an ARG query projects the 'id' field in the response, then Search-AzGraph adds a duplicate ResourceId property to the returned object.

Steps to reproduce

PS C:\Users\x>> (Search-AzGraph -Query "resources | project id" -Subscription $Subscriptions).data[0] | fl

id : /subscriptions/1234569a5-bb15-47c4-939c-4b66d5a7de05/resourceGroups/DefaultResourceGroup-CQ/providers/Microsoft.OperationalInsights/workspaces/DefaultWorkspace-1234569a5-bb15-47c4-939c-4b66d5a7de05-CQ
ResourceId : /subscriptions/1234569a5-bb15-47c4-939c-4b66d5a7de05/resourceGroups/DefaultResourceGroup-CQ/providers/Microsoft.OperationalInsights/workspaces/DefaultWorkspace-1234569a5-bb15-47c4-939c-4b66d5a7de05-CQ

This is happening in https://github.com/Azure/azure-powershell/blob/main/src/ResourceGraph/ResourceGraph/Utilities/ResultExtensions.cs

                if (row.TryGetValue(IdColumnName, out var idValue))
                {
                    // Best effort on resource id piping
                    rowObject.Properties.Add(new PSNoteProperty(
                        name: ResourceIdColumnName,
                        value: idValue));
                }

Impact

Using Azure Functions orchestration to query ARG and get a list of resource ids to take action on, sending each of those resource ids to an activity function to process. The way Azure Functions orchestration works is that the runtime serializes the object (the full ARG query results) to Azure Storage tables then deserializes back from storage as it processes them. This can happen thousands of times for a single processing run.

With the duplicated ResourceId property in the Search-AzGraph results, this is effectively doubling the size of the object that has to be serialized to and from storage, causing significant impacts on storage consumption and throttling, network IO, serialization processing time, etc.

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @chiragg4u.

Issue Details
## Description If an ARG query projects the 'id' field in the response, then Search-AzGraph adds a duplicate ResourceId property to the returned object. ## Steps to reproduce ```powershell PS C:\Users\x>> (Search-AzGraph -Query "resources | project id" -Subscription $Subscriptions).data[0] | fl id : /subscriptions/1234569a5-bb15-47c4-939c-4b66d5a7de05/resourceGroups/DefaultResourceGroup-CQ/providers/Microsoft.OperationalInsights/workspaces/DefaultWorkspace-1234569a5-bb15-47c4-939c-4b66d5a7de05-CQ ResourceId : /subscriptions/1234569a5-bb15-47c4-939c-4b66d5a7de05/resourceGroups/DefaultResourceGroup-CQ/providers/Microsoft.OperationalInsights/workspaces/DefaultWorkspace-1234569a5-bb15-47c4-939c-4b66d5a7de05-CQ ``` This is happening in https://github.com/Azure/azure-powershell/blob/main/src/ResourceGraph/ResourceGraph/Utilities/ResultExtensions.cs ``` if (row.TryGetValue(IdColumnName, out var idValue)) { // Best effort on resource id piping rowObject.Properties.Add(new PSNoteProperty( name: ResourceIdColumnName, value: idValue)); } ``` ## Impact Using Azure Functions orchestration to query ARG and get a list of resource ids to take action on, sending each of those resource ids to an activity function to process. The way Azure Functions orchestration works is that the runtime serializes the object (the full ARG query results) to Azure Storage tables then deserializes back from storage as it processes them. This can happen thousands of times for a single processing run. With the duplicated ResourceId property in the Search-AzGraph results, this is effectively doubling the size of the object that has to be serialized to and from storage, causing significant impacts on storage consumption and throttling, network IO, serialization processing time, etc.
Author: kwill-MSFT
Assignees: -
Labels: `Service Attention`, `Resource Graph`
Milestone: -