Partager via


Query - Usage

Interrogez les données d’utilisation pour l’étendue définie.

POST https://management.azure.com/{scope}/providers/Microsoft.CostManagement/query?api-version=2024-08-01

Paramètres URI

Nom Dans Obligatoire Type Description
scope
path True

string

Étendue associée aux opérations de requête et d’exportation. Cela inclut « /subscriptions/{subscriptionId} / » pour l’étendue de l’abonnement, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' pour l’étendue resourceGroup, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' pour l’étendue du compte de facturation et '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departmentId}' for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{ enrollmentAccountId} pour l’étendue EnrollmentAccount, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' pour l’étendue billingProfile, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' pour l’étendue invoiceSection et '/providers/Microsoft. Billing/billingAccounts/{billingAccountId}/customers/{customerId}' spécifique aux partenaires.

api-version
query True

string

Version de l’API à utiliser pour cette opération.

Corps de la demande

Nom Obligatoire Type Description
dataset True

QueryDataset

A la définition des données dans cette requête.

timeframe True

TimeframeType

Délai d’extraction des données pour la requête. Si elle est personnalisée, une période spécifique doit être fournie.

type True

ExportType

Type de la requête.

timePeriod

QueryTimePeriod

Dispose d’une période pour extraire des données pour la requête.

Réponses

Nom Type Description
200 OK

QueryResult

D’ACCORD. La demande a réussi.

204 No Content

Aucun contenu. La ressource n’est pas disponible.

Other Status Codes

ErrorResponse

Réponse d’erreur décrivant pourquoi l’opération a échoué.

Sécurité

azure_auth

Flux OAuth2 Azure Active Directory.

Type: oauth2
Flux: implicit
URL d’autorisation: https://login.microsoftonline.com/common/oauth2/authorize

Étendues

Nom Description
user_impersonation emprunter l’identité de votre compte d’utilisateur

Exemples

BillingAccountQuery-Legacy
BillingAccountQuery-MCA
BillingAccountQueryGrouping-Legacy
BillingAccountQueryGrouping-MCA
BillingProfileQuery-MCA
BillingProfileQueryGrouping-MCA
CustomerQuery-MCA
CustomerQueryGrouping-MCA
DepartmentQuery-Legacy
DepartmentQueryGrouping-Legacy
EnrollmentAccountQuery-Legacy
EnrollmentAccountQueryGrouping-Legacy
InvoiceSectionQuery-MCA
InvoiceSectionQueryGrouping-MCA
ManagementGroupQuery-Legacy
ManagementGroupQueryGrouping-Legacy
ResourceGroupQuery-Legacy
ResourceGroupQueryGrouping-Legacy
SubscriptionQuery-Legacy
SubscriptionQueryGrouping-Legacy

BillingAccountQuery-Legacy

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

BillingAccountQuery-MCA

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

BillingAccountQueryGrouping-Legacy

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

BillingAccountQueryGrouping-MCA

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

BillingProfileQuery-MCA

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

BillingProfileQueryGrouping-MCA

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

CustomerQuery-MCA

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

CustomerQueryGrouping-MCA

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

DepartmentQuery-Legacy

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

DepartmentQueryGrouping-Legacy

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

EnrollmentAccountQuery-Legacy

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

EnrollmentAccountQueryGrouping-Legacy

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "Daily",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ]
    ]
  }
}

InvoiceSectionQuery-MCA

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

InvoiceSectionQueryGrouping-MCA

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        "USD"
      ]
    ]
  }
}

ManagementGroupQuery-Legacy

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        0.16677720329728665,
        "gs-stms-dev",
        20180331,
        "USD"
      ]
    ]
  }
}

ManagementGroupQueryGrouping-Legacy

Exemple de requête

POST https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "name": "ad67fd91-c131-4bda-9ba9-7187ecb1cebd",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": "https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D",
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        20.35941656262545,
        "VSTSHOL-1595322048000",
        20180331,
        "USD"
      ],
      [
        173.41979241290323,
        "RVIIOT-TRIAL",
        20180331,
        "USD"
      ],
      [
        19.545363672276512,
        "JapanUnifia-Trial",
        20180331,
        "USD"
      ]
    ]
  }
}

ResourceGroupQuery-Legacy

Exemple de requête

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "subscriptions/55312978-ba1b-415c-9304-c4b9c43c0481/resourcegroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/Query/9af9459d-441d-4055-9ed0-83d4c4a363fb",
  "name": "9af9459d-441d-4055-9ed0-83d4c4a363fb",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": null,
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        2.10333307059661,
        "ScreenSharingTest-peer",
        20180417,
        "USD"
      ],
      [
        20.10333307059661,
        "ScreenSharingTest-peer",
        20180418,
        "USD"
      ]
    ]
  }
}

ResourceGroupQueryGrouping-Legacy

Exemple de requête

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "Daily",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceType"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/Query/9af9459d-441d-4055-9ed0-83d4c4a363fb",
  "name": "9af9459d-441d-4055-9ed0-83d4c4a363fb",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": null,
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceType",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        2.10333307059661,
        "Microsoft.SqlServer",
        20180417,
        "USD"
      ],
      [
        20.10333307059661,
        "Microsoft.Compute",
        20180418,
        "USD"
      ]
    ]
  }
}

SubscriptionQuery-Legacy

Exemple de requête

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "MonthToDate",
  "dataset": {
    "granularity": "Daily",
    "filter": {
      "and": [
        {
          "or": [
            {
              "dimensions": {
                "name": "ResourceLocation",
                "operator": "In",
                "values": [
                  "East US",
                  "West Europe"
                ]
              }
            },
            {
              "tags": {
                "name": "Environment",
                "operator": "In",
                "values": [
                  "UAT",
                  "Prod"
                ]
              }
            }
          ]
        },
        {
          "dimensions": {
            "name": "ResourceGroup",
            "operator": "In",
            "values": [
              "API"
            ]
          }
        }
      ]
    }
  }
}

Exemple de réponse

{
  "id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/Query/00000000-0000-0000-0000-000000000000",
  "name": "55312978-ba1b-415c-9304-cfd9c43c0481",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": null,
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "UsageDate",
        "type": "Number"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        2.10333307059661,
        "ScreenSharingTest-peer",
        20180331,
        "USD"
      ],
      [
        218.68795741935486,
        "Ict_StratAndPlan_GoldSprova_Prod",
        20180331,
        "USD"
      ],
      [
        0.14384913581657052,
        "ssbciotelement01",
        20180401,
        "USD"
      ],
      [
        0.009865586851323632,
        "ict_stratandplan_goldsprova_prod",
        20180429,
        "USD"
      ]
    ]
  }
}

SubscriptionQueryGrouping-Legacy

Exemple de requête

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/query?api-version=2024-08-01

{
  "type": "Usage",
  "timeframe": "TheLastMonth",
  "dataset": {
    "granularity": "None",
    "aggregation": {
      "totalCost": {
        "name": "PreTaxCost",
        "function": "Sum"
      }
    },
    "grouping": [
      {
        "type": "Dimension",
        "name": "ResourceGroup"
      }
    ]
  }
}

Exemple de réponse

{
  "id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/Query/00000000-0000-0000-0000-000000000000",
  "name": "55312978-ba1b-415c-9304-cfd9c43c0481",
  "type": "microsoft.costmanagement/Query",
  "properties": {
    "nextLink": null,
    "columns": [
      {
        "name": "PreTaxCost",
        "type": "Number"
      },
      {
        "name": "ResourceGroup",
        "type": "String"
      },
      {
        "name": "Currency",
        "type": "String"
      }
    ],
    "rows": [
      [
        0.009865586851323632,
        "Ict_StratAndPlan_GoldSprova_Prod_0",
        "USD"
      ],
      [
        218.68795741935486,
        "Ict_StratAndPlan_GoldSprova_Prod_1",
        "USD"
      ],
      [
        2.10333307059661,
        "ScreenSharingTest-peer1",
        "USD"
      ],
      [
        0.14384913581657052,
        "Ssbciotelement01",
        "USD"
      ]
    ]
  }
}

Définitions

Nom Description
ErrorDetails

Détails de l’erreur.

ErrorResponse

La réponse d’erreur indique que le service n’est pas en mesure de traiter la requête entrante. La raison est fournie dans le message d’erreur.

Réponses d’erreur :

  • 429 TooManyRequests : la requête est limitée. Réessayez après avoir attendu l’heure spécifiée dans l’en-tête « x-ms-ratelimit-microsoft.consumption-retry-after ».

  • 503 ServiceUnavailable - Le service est temporairement indisponible. Réessayez après avoir attendu l’heure spécifiée dans l’en-tête « Retry-After ».

ExportType

Type de la requête.

FunctionType

Nom de la fonction d’agrégation à utiliser.

GranularityType

Granularité des lignes dans la prévision.

QueryAggregation

Expression d’agrégation à utiliser dans la requête.

QueryColumn

Propriétés QueryColumn

QueryColumnType

Type de la colonne dans l’exportation.

QueryComparisonExpression

Expression de comparaison à utiliser dans la requête.

QueryDataset

Définition des données présentes dans la requête.

QueryDatasetConfiguration

Configuration du jeu de données dans la requête.

QueryDefinition

Définition d’une requête.

QueryFilter

Expression de filtre à utiliser dans l’exportation.

QueryGrouping

Groupe par expression à utiliser dans la requête.

QueryOperatorType

Opérateur à utiliser pour la comparaison.

QueryResult

Résultat de la requête. Elle contient toutes les colonnes répertoriées sous regroupements et agrégation.

QueryTimePeriod

Date de début et de fin de l’extraction des données pour la requête.

TimeframeType

Délai d’extraction des données pour la requête. Si elle est personnalisée, une période spécifique doit être fournie.

ErrorDetails

Détails de l’erreur.

Nom Type Description
code

string

Code d’erreur.

message

string

Message d’erreur indiquant pourquoi l’opération a échoué.

ErrorResponse

La réponse d’erreur indique que le service n’est pas en mesure de traiter la requête entrante. La raison est fournie dans le message d’erreur.

Réponses d’erreur :

  • 429 TooManyRequests : la requête est limitée. Réessayez après avoir attendu l’heure spécifiée dans l’en-tête « x-ms-ratelimit-microsoft.consumption-retry-after ».

  • 503 ServiceUnavailable - Le service est temporairement indisponible. Réessayez après avoir attendu l’heure spécifiée dans l’en-tête « Retry-After ».

Nom Type Description
error

ErrorDetails

Détails de l’erreur.

ExportType

Type de la requête.

Nom Type Description
ActualCost

string

AmortizedCost

string

Usage

string

FunctionType

Nom de la fonction d’agrégation à utiliser.

Nom Type Description
Sum

string

GranularityType

Granularité des lignes dans la prévision.

Nom Type Description
Daily

string

QueryAggregation

Expression d’agrégation à utiliser dans la requête.

Nom Type Description
function

FunctionType

Nom de la fonction d’agrégation à utiliser.

name

string

Nom de la colonne à agréger.

QueryColumn

Propriétés QueryColumn

Nom Type Description
name

string

Nom de la colonne.

type

string

Type de colonne.

QueryColumnType

Type de la colonne dans l’exportation.

Nom Type Description
Dimension

string

Dimension des données de coût.

TagKey

string

Balise associée aux données de coût.

QueryComparisonExpression

Expression de comparaison à utiliser dans la requête.

Nom Type Description
name

string

Nom de la colonne à utiliser en comparaison.

operator

QueryOperatorType

Opérateur à utiliser pour la comparaison.

values

string[]

Tableau de valeurs à utiliser pour la comparaison

QueryDataset

Définition des données présentes dans la requête.

Nom Type Description
aggregation

<string,  QueryAggregation>

Dictionnaire d’expression d’agrégation à utiliser dans la requête. La clé de chaque élément du dictionnaire est l’alias de la colonne agrégée. La requête peut avoir jusqu’à 2 clauses d’agrégation.

configuration

QueryDatasetConfiguration

Contient des informations de configuration pour les données de l’exportation. La configuration est ignorée si l’agrégation et le regroupement sont fournis.

filter

QueryFilter

Expression de filtre à utiliser dans la requête. Reportez-vous à notre documentation REST de l’API de requête pour savoir comment mettre correctement en forme le filtre.

granularity

GranularityType

Granularité des lignes dans la requête.

grouping

QueryGrouping[]

Tableau de groupes par expression à utiliser dans la requête. La requête peut avoir jusqu’à 2 clauses group by.

QueryDatasetConfiguration

Configuration du jeu de données dans la requête.

Nom Type Description
columns

string[]

Tableau de noms de colonnes à inclure dans la requête. Tout nom de colonne de requête valide est autorisé. Si elle n’est pas fournie, la requête inclut toutes les colonnes.

QueryDefinition

Définition d’une requête.

Nom Type Description
dataset

QueryDataset

A la définition des données dans cette requête.

timePeriod

QueryTimePeriod

Dispose d’une période pour extraire des données pour la requête.

timeframe

TimeframeType

Délai d’extraction des données pour la requête. Si elle est personnalisée, une période spécifique doit être fournie.

type

ExportType

Type de la requête.

QueryFilter

Expression de filtre à utiliser dans l’exportation.

Nom Type Description
and

QueryFilter[]

Expression logique « AND ». Doit avoir au moins 2 éléments.

dimensions

QueryComparisonExpression

A une expression de comparaison pour une dimension

or

QueryFilter[]

Expression logique « OR ». Doit avoir au moins 2 éléments.

tags

QueryComparisonExpression

A une expression de comparaison pour une balise

QueryGrouping

Groupe par expression à utiliser dans la requête.

Nom Type Description
name

string

Nom de la colonne à regrouper.

type

QueryColumnType

A le type de la colonne à regrouper.

QueryOperatorType

Opérateur à utiliser pour la comparaison.

Nom Type Description
In

string

QueryResult

Résultat de la requête. Elle contient toutes les colonnes répertoriées sous regroupements et agrégation.

Nom Type Description
eTag

string

ETag de la ressource.

id

string

ID de ressource.

location

string

Emplacement de la ressource.

name

string

Nom de la ressource.

properties.columns

QueryColumn[]

Tableau de colonnes

properties.nextLink

string

Lien (URL) vers la page suivante des résultats.

properties.rows

Rows[]

Tableau de lignes

sku

string

Référence SKU de la ressource.

tags

object

Balises de ressource.

type

string

Type de ressource.

QueryTimePeriod

Date de début et de fin de l’extraction des données pour la requête.

Nom Type Description
from

string

Date de début à partir de laquelle extraire des données.

to

string

Date de fin vers laquelle extraire des données.

TimeframeType

Délai d’extraction des données pour la requête. Si elle est personnalisée, une période spécifique doit être fournie.

Nom Type Description
BillingMonthToDate

string

Custom

string

MonthToDate

string

TheLastBillingMonth

string

TheLastMonth

string

WeekToDate

string