问题描述
我正在尝试使用.net core 3开发用于Azure功能中CSP的Azure计费的API 任何指导将不胜感激。
解决方法
安装Powershell:
Install-Package Microsoft.Azure.Management.Billing
代码示例:
/* 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();
只需执行以下步骤:
https://docs.microsoft.com/en-us/dotnet/api/overview/azure/billing
以上代码基于C#,您需要首先创建一个AAD应用注册。