how to develop Azure CSP billing Api in azure functions using .net core

243 views Asked by At

I am trying to develop an API for azure billing for CSP in azure functions using .net core 3 any guidance will be appreciated.

how do I call a billing API from the azure function?

1

There are 1 answers

1
Camden Bruce On

install with powershell:

Install-Package Microsoft.Azure.Management.Billing

code example:

/* Include these directives
using Microsoft.Rest.Azure.Authentication;
using Microsoft.Azure.Management.Billing;
using Microsoft.Azure.Management.Billing.Models;
*/

// Log into Azure
var serviceCreds = ApplicationTokenProvider.LoginSilentAsync(tenantId, clientId, secret);
var billingClient = new BillingClient(serviceCreds);
billingClient.SubscriptionId = subscriptionId;

// Get list of invoices
billingClient.Invoices.List();

Just follow below steps:

https://learn.microsoft.com/en-us/dotnet/api/overview/azure/billing

Above code is based on C#, you need to create a AAD app register first.