Azure:使用 BillingManagementClient class 获取发票数据
Azure: getting invoice data with the BillingManagementClient class
以下代码的最后一行导致 "Operation returned an invalid status code 'BadRequest'" 异常,我不明白为什么:
给定以下代码:
var tenantDomain = ConfigurationManager.AppSettings["TenantDomain"];
var clientId = ConfigurationManager.AppSettings["ClientID"];
var secret = ConfigurationManager.AppSettings["ClientSecret"];
var subscriptionId = ConfigurationManager.AppSettings["SubscriptionID"];
var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantDomain, clientId, secret);
var bmc = new BillingManagementClient(serviceCreds);
bmc.SubscriptionId = subscriptionId;
List<Invoice> allInvoices = bmc.Invoices.List().ToList();
有什么建议吗?我应该明确指定日期吗?怎么样?
Suggestions anyone ? Should I specify a date period explicitly ? How?
如果我们想要访问账单,我们需要将账单 Reader 角色分配给需要访问订阅账单的人。我们可以得到azure官方的详细步骤tutorials. I also test the code you mentioned, there is no issue with code, if it is supported. The following is the snippet from the official tutorials.
The Billing Reader feature is in preview, and does not yet support enterprise (EA) subscriptions or non-global clouds.
请尝试登录 Azure Portal 检查是否可以 访问发票 。如果您看到 发票访问 被禁用,似乎不支持订阅类型。
如果您还有其他问题,可以contact support快速解决您的问题。
以下代码的最后一行导致 "Operation returned an invalid status code 'BadRequest'" 异常,我不明白为什么:
给定以下代码:
var tenantDomain = ConfigurationManager.AppSettings["TenantDomain"];
var clientId = ConfigurationManager.AppSettings["ClientID"];
var secret = ConfigurationManager.AppSettings["ClientSecret"];
var subscriptionId = ConfigurationManager.AppSettings["SubscriptionID"];
var serviceCreds = await ApplicationTokenProvider.LoginSilentAsync(tenantDomain, clientId, secret);
var bmc = new BillingManagementClient(serviceCreds);
bmc.SubscriptionId = subscriptionId;
List<Invoice> allInvoices = bmc.Invoices.List().ToList();
有什么建议吗?我应该明确指定日期吗?怎么样?
Suggestions anyone ? Should I specify a date period explicitly ? How?
如果我们想要访问账单,我们需要将账单 Reader 角色分配给需要访问订阅账单的人。我们可以得到azure官方的详细步骤tutorials. I also test the code you mentioned, there is no issue with code, if it is supported. The following is the snippet from the official tutorials.
The Billing Reader feature is in preview, and does not yet support enterprise (EA) subscriptions or non-global clouds.
请尝试登录 Azure Portal 检查是否可以 访问发票 。如果您看到 发票访问 被禁用,似乎不支持订阅类型。
如果您还有其他问题,可以contact support快速解决您的问题。