-
Notifications
You must be signed in to change notification settings - Fork 203
[Power BI] Address ARG payload size errors #1849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
728740f
605f8c1
0de9cd4
5ce647c
f6e3808
d43608a
5ac8624
3e52374
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -89,6 +89,45 @@ expression ftk_DemoFilter = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| annotation PBI_ResultType = Function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Number of subscriptions to include in each Azure Resource Graph query batch. Decrease if you experience payload limit errors. Default: 100. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expression ftk_ARGBatchSize = () => 100 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lineageTag: f7a1b2c3-d4e5-6789-0abc-def123456789 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryGroup: Functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| annotation PBI_NavigationStepName = Navigation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| annotation PBI_ResultType = Function | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Queries Azure Resource Graph in batches of subscriptions and combines results to avoid the 16 MB payload limit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expression ftk_QueryARG = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (query as text, optional batchMultiplier as number) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| batchSize = ftk_ARGBatchSize() * (if batchMultiplier <> null then batchMultiplier else 1), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subQuery = "resourcecontainers | where type == 'microsoft.resources/subscriptions' | project subscriptionId" & ftk_DemoFilter(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Subscriptions = AzureResourceGraph.Query(subQuery, "Tenant", null, null, [resultTruncated = false]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SubscriptionIds = Subscriptions[subscriptionId], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| BatchCount = Number.RoundUp(List.Count(SubscriptionIds) / batchSize), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Batches = List.Transform({0..BatchCount-1}, each | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| batchStart = _ * batchSize, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| batchIds = List.Range(SubscriptionIds, batchStart, List.Min({batchSize, List.Count(SubscriptionIds) - batchStart})), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+105
to
+113
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subFilter = " | where subscriptionId in (" & Text.Combine(List.Transform(batchIds, each "'" & _ & "'"), ",") & ")", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fullQuery = query & subFilter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Source = AzureResourceGraph.Query(fullQuery, "Tenant", null, null, [resultTruncated = false]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if Table.HasColumns(Source, "Results") and Table.RowCount(Source) = 1 then null else Source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Filtered = List.RemoveNulls(Batches), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Combined = if List.Count(Filtered) > 0 then Table.Combine(Filtered) else null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+105
to
+121
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| batchSize = ftk_ARGBatchSize() * (if batchMultiplier <> null then batchMultiplier else 1), | |
| subQuery = "resourcecontainers | where type == 'microsoft.resources/subscriptions' | project subscriptionId" & ftk_DemoFilter(), | |
| Subscriptions = AzureResourceGraph.Query(subQuery, "Tenant", null, null, [resultTruncated = false]), | |
| SubscriptionIds = Subscriptions[subscriptionId], | |
| BatchCount = Number.RoundUp(List.Count(SubscriptionIds) / batchSize), | |
| Batches = List.Transform({0..BatchCount-1}, each | |
| let | |
| batchStart = _ * batchSize, | |
| batchIds = List.Range(SubscriptionIds, batchStart, List.Min({batchSize, List.Count(SubscriptionIds) - batchStart})), | |
| subFilter = " | where subscriptionId in (" & Text.Combine(List.Transform(batchIds, each "'" & _ & "'"), ",") & ")", | |
| fullQuery = query & subFilter, | |
| Source = AzureResourceGraph.Query(fullQuery, "Tenant", null, null, [resultTruncated = false]) | |
| in | |
| if Table.HasColumns(Source, "Results") and Table.RowCount(Source) = 1 then null else Source | |
| ), | |
| Filtered = List.RemoveNulls(Batches), | |
| Combined = if List.Count(Filtered) > 0 then Table.Combine(Filtered) else null | |
| // determine effective batch size, allowing an optional multiplier | |
| batchSize = ftk_ARGBatchSize() * (if batchMultiplier <> null then batchMultiplier else 1), | |
| // query Azure Resource Graph for the list of subscriptions in scope | |
| subQuery = "resourcecontainers | where type == 'microsoft.resources/subscriptions' | project subscriptionId" & ftk_DemoFilter(), | |
| Subscriptions = AzureResourceGraph.Query(subQuery, "Tenant", null, null, [resultTruncated = false]), | |
| // validate that the subscription query returned a usable table with a subscriptionId column | |
| ValidSubscriptions = | |
| if Subscriptions <> null | |
| and Table.HasColumns(Subscriptions, "subscriptionId") | |
| and Table.RowCount(Subscriptions) > 0 | |
| then | |
| Subscriptions | |
| else | |
| null, | |
| // short-circuit with null if we cannot retrieve a valid subscription list | |
| Combined = | |
| if ValidSubscriptions = null then | |
| null | |
| else | |
| let | |
| SubscriptionIds = ValidSubscriptions[subscriptionId], | |
| BatchCount = Number.RoundUp(List.Count(SubscriptionIds) / batchSize), | |
| Batches = List.Transform( | |
| {0 .. BatchCount - 1}, | |
| each | |
| let | |
| batchStart = _ * batchSize, | |
| batchIds = List.Range( | |
| SubscriptionIds, | |
| batchStart, | |
| List.Min({ batchSize, List.Count(SubscriptionIds) - batchStart }) | |
| ), | |
| subFilter = " | where subscriptionId in (" & Text.Combine(List.Transform(batchIds, each "'" & _ & "'"), ",") & ")", | |
| fullQuery = query & subFilter, | |
| Source = AzureResourceGraph.Query(fullQuery, "Tenant", null, null, [resultTruncated = false]) | |
| in | |
| // handle the single-row "Results" shape by treating it as an empty result | |
| if Table.HasColumns(Source, "Results") and Table.RowCount(Source) = 1 then null else Source | |
| ), | |
| Filtered = List.RemoveNulls(Batches) | |
| in | |
| if List.Count(Filtered) > 0 then Table.Combine(Filtered) else null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description states this is documentation-only / no code changes, but this changelog entry (and the accompanying .tmdl changes) indicate functional report query changes (ARG batching/pagination). Please update the PR description to reflect the code changes and include any validation/testing done for the updated Power Query logic.