適用於 Node.js 的 Azure 計費模組Azure Billing modules for Node.js

概觀Overview

Azure 計費 API 可供存取您的 Azure 計費資訊和發票。The Azure Billing APIs provide access to your Azure billing information and invoices.

若要使用此 API,帳戶管理員必須透過 Azure 入口網站選擇加入。To use this API, the account admin must opt in via the Azure portal. 請參閱使用角色來管理對 Azure 帳單的存取See Manage access to Azure billing using roles.

安裝 npm 模組Install the npm module

安裝 Azure 計費 npm 模組Install the Azure Billing npm module

npm install azure-arm-billing

範例Example

此範例會列印您過去所有發票的清單。This example prints a list of all of your past invoices.

const msRestAzure = require('ms-rest-azure');
const BillingManagement = require('azure-arm-billing');

const subscriptionId = 'your-subscription-id';

msRestAzure
  .interactiveLogin()
  .then(credentials => {
    let client = new BillingManagement(credentials, subscriptionId);
    return client.invoices.list();
  })
  .then(invoices => {
    console.log('List of invoices:');
    console.dir(invoices, { depth: null, colors: true });
  });

範例Samples

深入探索可在應用程式中使用的 Node.js 程式碼範例Explore more sample Node.js code you can use in your apps.