Exporting Cost Consumption using Logic App, Output is getting merged
we are trying to exporting the cost consumption of a particular Resource Group using Rest API, and exporting the data through email as attachment, but the data is getting merged and unable to read need to separate the columns of output file
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Append_to_array_variable": {
"inputs": {
"name": "test1",
"value": "@Tomas Podoba ('Parse_JSON')"
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "AppendToArrayVariable"
},
"Create_HTML_table": {
"inputs": {
"format": "HTML",
"from": "@Tomas Podoba ('Select')"
},
"runAfter": {
"Select": [
"Succeeded"
]
},
"type": "Table"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "test1",
"type": "array"
}
]
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Parse_JSON": {
"inputs": {
"content": "@triggerBody()",
"schema": {
"properties": {
"Pretaxcost": {
"properties": {
"name": {
"type": "string"
},
"operator": {
"type": "string"
},
"values": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"ResourceType": {
"properties": {
"name": {
"type": "string"
},
"operator": {
"type": "string"
},
"values": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"dataset": {
"properties": {
"MeterCategory": {
"properties": {
"name": {
"type": "string"
},
"operator": {
"type": "string"
},
"values": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"aggregation": {
"properties": {
"totalCost": {
"properties": {
"function": {
"type": "string"
},
"name": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"granularity": {
"type": "string"
},
"grouping": {
"items": {
"properties": {
"name": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"name",
"type"
],
"type": "object"
},
"type": "array"
}
},
"type": "object"
},
"timeframe": {
"type": "string"
},
"type": {
"type": "string"
}
},
"type": "object"
}
},
"runAfter": {},
"type": "ParseJson"
},
"Select": {
"inputs": {
"from": "@variables('test1')",
"select": {
"Properties": "@Shay (variables('test1'))['Properties']"
}
},
"runAfter": {
"Append_to_array_variable": [
"Succeeded"
]
},
"type": "Select"
},
"Send_an_email_(V2)_2": {
"inputs": {
"body": {
"Attachments": [
{
"ContentBytes": "@{base64(body('Create_HTML_table'))}",
"Name": "Test"
}
],
"Body": "<p>Test</p>",
"Subject": "Test",
"To": "******@sonata-software.com"
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {
"Create_HTML_table": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"HTTP": {
"evaluatedRecurrence": {
"frequency": "Week",
"interval": 1
},
"inputs": {
"authentication": {
"audience": "https://management.azure.com",
"type": "ManagedServiceIdentity"
},
"body": {
"dataset": {
"aggregation": {
"totalCost": {
"function": "Sum",
"name": "PreTaxCost"
}
},
"granularity": "Daily",
"grouping": [
{
"name": "resourcelocation",
"type": "Dimension"
},
{
"name": "MeterCategory",
"type": "Dimension"
},
{
"name": "resourcetype",
"type": "Dimension"
}
]
},
"timeframe": "TheLastMonth",
"type": "Usage"
},
"method": "POST",
"uri": "https://management.azure.com/subscriptions/xxxxxx-fcf4-4927-a56b-9a856a97b9e4/resourceGroups/BillingCodeAutomation/providers/Microsoft.CostManagement/query?api-version=2021-10-01"
},
"recurrence": {
"frequency": "Week",
"interval": 1
},
"type": "Http"
}
}
},
"parameters": {
"$connections": {
"value": {
"office365": {
"connectionId": "/subscriptions/xxxxxxx-fcf4-4927-a56b-9a856a97b9e4/resourceGroups/reportautmation/providers/Microsoft.Web/connections/office365-7",
"connectionName": "office365-7",
"id": "/subscriptions/xxxxxxx-fcf4-4927-a56b-9a856a97b9e4/providers/Microsoft.Web/locations/eastus/managedApis/office365"
}
}
}
}
}