Alon
Alon

Reputation: 11905

azure-arm-consumption: get consumption with a CSP subscription

In my Node.js project I am trying to use azure-arm-consumption package to get the current consumption/billing.

My code:

const MsRest = require('ms-rest-azure');
MsRest.loginWithServicePrincipalSecret(keys.appId, keys.pass, keys.tenantId);
const { ConsumptionManagementClient } = require('azure-arm-consumption');
const client = new ConsumptionManagementClient (credentials, subscriptionId);
const cost = client.forecasts.list(subscriptionId);

The last line throws an error saying that this method only works for an EA subscription (which makes sense, I use a CSP subscription).

Which method in this API can be used for CSP subscription?

Upvotes: 1

Views: 172

Answers (1)

Rick Rainey
Rick Rainey

Reputation: 11256

The consumption API's are not supported for CSP subscriptions. See list of unsupported subscription types here.

You could get this information using the portal though. In the Azure portal, open the subscription blade for your subscription (Home > Subscriptions > Your Subscription). Then, click on Cost Analysis under the Cost Management section. From there, you can get your consumption by resource, resource group, tag, etc. Then you can export it to a CSV file.

Upvotes: 2

Related Questions