Azure / Azure/azure-powershell
`Invoke-AzCostManagementQuery` often does not return results on first try. Throttling?
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
I experience that `Invoke-AzCostManagementQuery` often does not return results on first try. Seems the Rest API endpoint it uses is unstable. If I retry once or sometimes even twice, the success rate becomes better.
Can Az do something about this? Add some retry logic or something?
### Issue script & Debug output
```PowerShell
$null = Add-Member -InputObject $Subscription -Force -NotePropertyName 'ConsumptionTwoWeeksAgo' -NotePropertyValue (
Invoke-AzCostManagementQuery -WhatIf:$false -DatasetAggregation @{
'totalCost' = @{
'name' = [string] 'Cost'
'function' = [string] 'SUM'
}
} -Type 'ActualCost' -Timeframe 'Custom' `
-Scope ('/subscriptions/{0}' -f $Subscription.'Id') `
-TimePeriodFrom $StartOfTwoWeeksAgo.ToString('o') `
-TimePeriodTo $EndOfTwoWeeksAgo.ToString('o') 6>$null
)
```
### Environment data
```PowerShell
PowerShell v7.5.1 x64
Windows 11 24H2 x64
```
### Module versions
```PowerShell
Az.Accounts 4.2.0
Az.CostManagement 0.4.0
```
### Error output
```PowerShell
No error
```
Contributor guide
Assessment
This issue has not been assessed yet.