0

I'm using get-azconsumptionusagedetails in Powershell to get consumption of all of the resources for azure sponsorship acc, but for some of the resources it won't show anything (no error either), even though they are in the same RG as the ones that work.

Does anyone know the reason behind it?

I'm using

Get-AzConsumptionUsageDetail -InstanceName $r.Name
Venkat V
  • 2,197
  • 1
  • 1
  • 10

1 Answers1

0

get-azconsumptiondetails won't work for some resources

I tried to fetch the resource usage details using Get-AzConsumptionUsageDetail cmdlet but it's not working properly and same is already reported in Github issue

Alternatively, you can check the Azure resource cost usage details in Azure CLI command.

$r = az consumption usage list | ConvertFrom-Json

foreach ($usageDetail in $r) {
    $instanceName = $usageDetail.instanceName
    $pretaxCost = $usageDetail.pretaxCost
    $usageQuantity = $usageDetail.usageQuantity
    $usageStart = $usageDetail.usageStart
    $usageEnd = $usageDetail.usageEnd
    
    Write-Host "Instance Name: $instanceName"
    Write-Host "Pretax Cost: $pretaxCost"
    Write-Host "Usage Quantity: $usageQuantity"
    Write-Host "Usage Start: $usageStart"
    Write-Host "Usage End: $usageEnd"
    Write-Host "=================================="
}

Output:

enter image description here

Reference: az consumption usage

Venkat V
  • 2,197
  • 1
  • 1
  • 10