Azure / Azure/azure-powershell

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

Open
#15,730 2 comments 0 reactions 0 assignees View on GitHub
act-identity-squad Resource Graph Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

## 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.