[英]Get total cost from Azure billing Invoice CSV file
I have added a schedule export for my Azure Resource Group Billing invoice on a monthly basis.我已按月为 Azure 资源组计费发票添加了计划导出。 The invoice generated will consist of the billing details of the Last Month and will store the .CSV file in my storage account as a Blob every month.
生成的发票将包含上个月的帐单详细信息,并将每月将 .CSV 文件作为 Blob 存储在我的存储帐户中。
I'm using an Azure Logic app to retrieve the Invoice file and send it via mail to a group of recipients.我正在使用 Azure 逻辑应用来检索发票文件并通过邮件将其发送给一组收件人。
The invoice is a .CSV file which consists of a number of columns like "InstanceID, MeterID, UsageQuantity, ResourceLocation".发票是一个 .CSV 文件,由许多列组成,如“InstanceID、MeterID、UsageQuantity、ResourceLocation”。 But I need to get the TOTAL COST for the billing period.
但我需要获得计费周期的总成本。
Any idea how I can achieve this?知道我如何实现这一目标吗? Is there a specific column that I need to include in my CSV file.
是否需要在我的 CSV 文件中包含特定的列。 Or do I need to do some sort of data processing of the CSV file to get the total amount of resources consumed?
或者我是否需要对 CSV 文件进行某种数据处理才能获得消耗的资源总量?
Any advise on this?对此有何建议? Thanks!
谢谢!
1. I created a csv file(named billing.csv
) as below and upload it to blob storage. 1.我创建了一个 csv 文件(名为
billing.csv
),如下所示并将其上传到 blob 存储。
InstanceID, MeterID, UsageQuantity, ResourceLocation, Pre tax cost
1,1,2,aa,10
2,2,3,bb,20
3,3,5,cc,30
2. In logic app, use " Get blob content " to get the csv file. 2.在逻辑应用程序中,使用“获取 blob 内容”来获取 csv 文件。
3. Search the action " Parse CSV " in you logic app. 3.在您的逻辑应用中搜索操作“解析 CSV ”。
4. The "Parse CSV" action will ask you to input "API Key", you need to go to this page first --> click "Start free trial", register an account and create a new API Key. 4. “解析CSV”动作会要求你输入“API Key”,你需要先到这个页面-->点击“开始免费试用”,注册一个账户并创建一个新的API Key。
Copy the secret and paste it to your logic app as "API key", it will allow you to connect Plumsail.
复制秘密并将其作为“API 密钥”粘贴到您的逻辑应用程序中,它将允许您连接 Plumsail。
5. Then choose the blob content into the "Parse CSV" and input the headers InstanceID, MeterID, UsageQuantity, ResourceLocation, Pre tax cost
. 5.然后选择 blob 内容到“解析 CSV”并输入标题
InstanceID, MeterID, UsageQuantity, ResourceLocation, Pre tax cost
。 Add a new parameter "Skip first line" and set its value as Yes
.添加一个新参数“跳过第一行”并将其值设置为
Yes
。
6. Initialize a variable sum
and set its value as 0
in integer type. 6.初始化一个变量
sum
并将其值设置为整数类型的0
。 Initialize another variable tempItem
and also set its value as 0
.初始化另一个变量
tempItem
并将其值设置为0
。
7. Use a " For each " loop. 7.使用“ For each ”循环。
The Body
comes from " Parse CSV " action and the expression of "value" is: add(variables('tempItem'), int(items('For_each')?['Pre tax cost']))
Body
来自“解析CSV ”动作,“值”的表达式为: add(variables('tempItem'), int(items('For_each')?['Pre tax cost']))
8. After running the logic app, we can see the sum
in last loop is: 8.运行逻辑应用程序后,我们可以看到最后一个循环中的
sum
为:
9. Here is the whole logic app for your reference: 9.这是整个逻辑应用程序供您参考:
Import:进口:
This solution uses the third party connector " Plumsail Documents ", I'm not sure if it is free.此解决方案使用第三方连接器“ Plumsail Documents ”,我不确定它是否免费。 I registered account in the past, it worked without any cost.
我过去注册了帐户,它没有任何费用。 But today the api key can't continue use, I need to register another account and create another api key.
但是今天这个api key不能继续使用了,需要重新注册一个账号,创建另一个api key。 So I think this third party connector need extra cost if you want to use it for a long time.
所以我认为这个第三方连接器如果你想长期使用它需要额外的成本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.