Skip to content

Get-AzCostManagementExport always returns empty even though Azure portal shows exports (export APIVersion issue) #26013

Open

Description

Description

I've tested this behavior on multiple Azure subscriptions in different tenants, all repro.

  1. Goto Azure subscription, Login with Admin User, and create an Export in Cost Management portal (in type of daily export current month cost)
  2. After it is created, I can see the cost export in the Exports list,
image 3. also check network request looks good: https://management.azure.com/subscriptions/3d1470c1-b155-4b2e-b3d4-03a20062840f/providers/Microsoft.CostManagement/exports?api-version=2023-07-01-preview&$expand=runHistory image

Now switch to Az module:

  1. Connect to the same Azure subscription using the same Admin User:
    Connect-AzAccount -Credential $psCred -Subscription 3d1470c1-b155-4b2e-b3d4-03a20062840f
image
  1. Get-AzCostManagementExport -Scope 'subscriptions/3d1470c1-b155-4b2e-b3d4-03a20062840f'
    Nothing returned

If you look at below Debug output, you can tell the powershell module is using apiversion 2021-10-01, but the portal is using new one in 2023, If i edit the network request to use the same api version as the PowerShell module, it returns nothing either:
image

Issue script & Debug output

DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /subscriptions/3d1470c1-b155-4b2e-b3d4-03a20062840f/providers/Microsoft.CostManagement/exports?api-version=2021-10-01
DEBUG: RequestCreated: /subscriptions/3d1470c1-b155-4b2e-b3d4-03a20062840f/providers/Microsoft.CostManagement/exports?api-version=2021-10-01
DEBUG: HeaderParametersAdded:
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/3d1470c1-b155-4b2e-b3d4-03a20062840f/providers/Microsoft.CostManagement/exports?api-version=2021-10-01

Headers:
x-ms-unique-id                : 7
x-ms-client-request-id        : c6086f18-b17e-484e-ba57-8045b4c395ba
CommandName                   : Get-AzCostManagementExport
FullCommandName               : Get-AzCostManagementExport_List
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v0.0.0,PSVersion/v7.4.5,Az.CostManagement/0.0.0

Body:



DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
Vary                          : Accept-Encoding
session-id                    : 7424d798-63e5-4d63-865c-d56e6c9b705b
x-ms-request-id               : 53414cde-e9ff-4538-9706-7726952ce794
x-ms-correlation-request-id   : 9943626c-ddfb-4371-9f7c-ff85b5478d59
x-ms-client-request-id        : c6086f18-b17e-484e-ba57-8045b4c395ba
X-Powered-By                  : ASP.NET
x-ms-ratelimit-remaining-subscription-reads: 499
x-ms-ratelimit-remaining-subscription-global-reads: 7499
x-ms-routing-request-id       : WESTUS2:20240904T225312Z:9943626c-ddfb-4371-9f7c-ff85b5478d59
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
X-Cache                       : CONFIG_NOCACHE
X-MSEdge-Ref                  : Ref A: 5A36C91BEDFA4CDAB1DFAF12F0F77727 Ref B: CO6AA3150220045 Ref C: 2024-09-04T22:53:11Z
Date                          : Wed, 04 Sep 2024 22:53:11 GMT

Body:
{
  "value": []
}


DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent:  Module: Az.CostManagement:0.3.2; CommandName: Get-AzCostManagementExport; PSVersion: 7.4.5; IsSuccess: True; Duration: 00:00:00.4049409; SanitizeDuration: 00:00:00.0000180

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.5
PSEdition                      Core
GitCommitId                    7.4.5
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     3.0.4                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzConte…
Script     0.3.2                 Az.CostManagement                   {Get-AzCostManagementExport, Get-AzCostManagement…
Script     7.4.0                 Az.Resources                        {Export-AzResourceGroup, Export-AzTemplateSpec, G…
Script     7.3.0                 Az.Storage                          {Add-AzRmStorageContainerLegalHold, Add-AzStorage

Error output

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Cost Management - QueryAll issues in cost management and Consumption for query API associated to tags, dimensions and forecGap - PortalService AttentionThis issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions