我正在尝试使用 .net core 3 为 Azure 功能中的 CSP 开发 Azure 计费 API,任何指导将不胜感激。
如何从 azure 函数调用计费 API?
我正在尝试使用 .net core 3 为 Azure 功能中的 CSP 开发 Azure 计费 API,任何指导将不胜感激。
如何从 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 应用程序寄存器。