azure-sdk-for-js/sdk/consumption/arm-consumption/samples-dev/reservationTransactionsList...

51 строка
1.7 KiB
TypeScript

/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import {
ReservationTransactionsListOptionalParams,
ConsumptionManagementClient
} from "@azure/arm-consumption";
import { DefaultAzureCredential } from "@azure/identity";
import * as dotenv from "dotenv";
dotenv.config();
/**
* This sample demonstrates how to List of transactions for reserved instances on billing account scope
*
* @summary List of transactions for reserved instances on billing account scope
* x-ms-original-file: specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationTransactionsListByEnrollmentNumber.json
*/
async function reservationTransactionsByEnrollmentNumber() {
const subscriptionId =
process.env["CONSUMPTION_SUBSCRIPTION_ID"] ||
"00000000-0000-0000-0000-000000000000";
const filter =
"properties/eventDate+ge+2020-05-20+AND+properties/eventDate+le+2020-05-30";
const billingAccountId = "123456";
const options: ReservationTransactionsListOptionalParams = { filter };
const credential = new DefaultAzureCredential();
const client = new ConsumptionManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (let item of client.reservationTransactions.list(
billingAccountId,
options
)) {
resArray.push(item);
}
console.log(resArray);
}
async function main() {
reservationTransactionsByEnrollmentNumber();
}
main().catch(console.error);