简体   繁体   中英

I cannot get monthly billing information. Why does my access to Azure Cost Management and consumption APIs fail to get this on a CSP azure offer?

I would like to retrieve billing information (Cost Management) via API, the cost each month. However, we are trying to follow the technical instructions provided but we are having problems (4xx errors). Can you give me any clue on why we are doing it wrong? We are doing it from an account that is billing owner on an enterprise account that is a child of the csp account, so according to this [6] it should work.

We tested the following: first with Azure Cost Management and then with Azure consumption APIs

  1. Query - Usage - REST API (Azure Cost Management) | Microsoft Docs [2] In our tests we could access the cost information in a pay-as-you-go subscription using Azure Cost Management. However, our company is supposed to have an Enterprise Agreement and a 4xx error appeared when testing this API:
{
  "error": {
    "code": "InvalidAuthenticationTokenTenant",
    "message": "The access token is from the wrong issuer 'https://sts.windows.net/AAAAA/'. It must match the tenant 'https://sts.windows.net/AAAAAA/' associated with this subscription. Please use the authority (URL) 'https://login.windows.net/AAAAAA' to get the token. Note, if the subscription is transferred to another tenant there is no impact to the services, but information about new tenant could take time to propagate (up to an hour). If you just transferred your subscription and see this error message, please try back later."
  }
}
  1. Balances - Get By Billing Account - REST API (Azure Consumption) | Microsoft Docs [3] The following error appeared:
{"error":{"code":"404","message":"No billing period information found for the specified Enrollments:XXXX:YYYYYY. (Request ID: 9c07729f-ed90-495f-b1fd-c3b1359a003f)"}}{"error":{"code":"404","message":"No billing period information found for the specified Enrollments:XXXX:YYYYYY. (Request ID: 9c07729f-ed90-495f-b1fd-c3b1359a003f)"}}

Then we followed this [4] and tried this [5] to give the proper access, but this error appear when accessing the API:

{
    “code”: “Unprocessability”,
    “message”: “PUT operation is currently supported only on EA billing accounts”
}

Finally, we submit an Azure ticket and it seems it was needed this body. Now it works:

{
    "type": "ActualCost",
    "dataSet": {
        "granularity": "Daily",
        "aggregation": {
            "totalCost": {
                "name": "Cost",
                "function": "Sum"
            }
        },
        "grouping": [
            {
                "type": "Dimension",
                "name": "ResourceId"
            },
            {
                "type": "Dimension",
                "name": "ChargeType"
            },
            {
                "type": "Dimension",
                "name": "PublisherType"
            }
        ]
    }
}
"timeframe": "MonthTodate"
}

PS: with custom time frame it works as follows:

  "timeframe": "Custom",

    "timePeriod": {

        "from": "2022-07-01T00:00:00+00:00",

        "to": "2022-07-31T23:59:59+00:00" }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM