Tuesday, 15 January 2019

azure-arm-consumption: get consumption of a resource group

In my Node.js project I am trying to use azure-arm-consumption package to get the current consumption/billing of a resource group. I mean, how much money was spent on this resource group until now.

Under Interfaces, from AggregatedCost to UsageDetails, all of these interfaces contain methods, but I just don't manage to find the method for reading how much money a specific resource group has consumed.

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);

It retrieves the consumption of my subscription divided by date. Now the problem is that I don't want it to be divided by date, but by resource group. Is there any method in this API that can do that?



from azure-arm-consumption: get consumption of a resource group

No comments:

Post a Comment