Кажется, что это слишком сложный способ сделать это, но я прошёл несколько преобразований, чтобы сначала превратить его в JSON, а затем добавить к переменной в нескольких для каждого цикла с concurrency set to enabled
и degree of parallelism set to 1
.
Я включил все выражения и разбиения в комментарии для каждого действия.
Теперь, если вы хотите сделать это одновременно для Demo1 и Demo2, вам нужно обернуть мое решение для обработки массивов.
Редактировать: я понимаю, что я создал массив в результате, но вы могли бы легко, когда вы продвинулись так далеко, вместо того, чтобы добавить все это в строку.
Код подключенияинформация, это и с onedrive и с хранилищем BLOB-объектов, в настоящее время подключены к хранилищу BLOB-объектов и окончательный вывод в таблицу Excel:
{
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/[GUID]/resourceGroups/StackOverFlow/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/[GUID]/providers/Microsoft.Web/locations/westeurope/managedApis/azureblob"
},
"excelonlinebusiness": {
"connectionId": "/subscriptions/[GUID]/resourceGroups/StackOverFlow/providers/Microsoft.Web/connections/excelonlinebusiness",
"connectionName": "excelonlinebusiness",
"id": "/subscriptions/[GUID]/providers/Microsoft.Web/locations/westeurope/managedApis/excelonlinebusiness"
},
"onedriveforbusiness": {
"connectionId": "/subscriptions/[GUID]/resourceGroups/StackOverFlow/providers/Microsoft.Web/connections/onedriveforbusiness",
"connectionName": "onedriveforbusiness",
"id": "/subscriptions/[GUID]/providers/Microsoft.Web/locations/westeurope/managedApis/onedriveforbusiness"
}
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "@body('Get_blob_content')",
"runAfter": {
"Get_blob_content": [
"Succeeded"
]
},
"type": "Compose"
},
"For_each_row": {
"actions": {
"Add_a_row_into_a_table": {
"inputs": {
"body": {
"Hours": "@body('Parse_JSON')?['PackageServiceId']",
"Id": "@body('Parse_JSON')?['ActiveUsers']",
"Name": "@body('Parse_JSON')?['AgreementID']"
},
"host": {
"connection": {
"name": "@parameters('$connections')['excelonlinebusiness']['connectionId']"
}
},
"method": "post",
"path": "/codeless/v1.2/drives/@{encodeURIComponent('[Some long hash]')}/items/@{encodeURIComponent('[Some long hash]')}/workbook/tables/@{encodeURIComponent('{[GUID]}')}/rows",
"queries": {
"source": "me"
}
},
"metadata": {
"[Some long hash]": "/LOL/Bok1.xlsx"
},
"runAfter": {
"clear_tempArray_for_next_row": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Clear_data_of_special_characters": {
"description": "replace(replace(replace(item(),'[',''),']',''),'\"','')",
"inputs": {
"name": "data",
"value": "@{replace(replace(replace(item(),'[',''),']',''),'\"','')}"
},
"runAfter": {},
"type": "SetVariable"
},
"For_each_item_on_row": {
"actions": {
"Append_to_tempArray": {
"description": "Create array to hold values before compose and json",
"inputs": {
"name": "tempArray",
"value": "@items('For_each_item_on_row')"
},
"runAfter": {},
"type": "AppendToArrayVariable"
}
},
"description": "split(variables('data'),',')",
"foreach": "@split(variables('data'),',')",
"runAfter": {
"Clear_data_of_special_characters": [
"Succeeded"
]
},
"type": "Foreach"
},
"Parse_JSON": {
"description": "Parse into json object",
"inputs": {
"content": "@variables('data')",
"schema": {
"properties": {
"ActiveUsers": {
"type": "string"
},
"AgreementID": {
"type": "string"
},
"PackageServiceId": {
"type": "string"
}
},
"type": "object"
}
},
"runAfter": {
"Set_data_to_json_formated_string": [
"Succeeded"
]
},
"type": "ParseJson"
},
"Set_data_to_json_formated_string": {
"description": "Create json string using tempArray: variables('tempArray')?[0] throu variables('tempArray')?[2]",
"inputs": {
"name": "data",
"value": "{\n\"AgreementID\":\"@{variables('tempArray')?[0]}\",\n\"PackageServiceId\":\"@{variables('tempArray')?[1]}\",\n\"ActiveUsers\":\"@{variables('tempArray')?[2]}\"\n}"
},
"runAfter": {
"For_each_item_on_row": [
"Succeeded"
]
},
"type": "SetVariable"
},
"clear_tempArray_for_next_row": {
"inputs": {
"name": "tempArray",
"value": "@null"
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "SetVariable"
}
},
"description": "split on newline in csv doc. @split(body('Get_file_content'),'\\r\\n')",
"foreach": "@split(outputs('Compose'),'\r\n')",
"runAfter": {
"Initialize_'data'_string": [
"Succeeded"
]
},
"runtimeConfiguration": {
"concurrency": {
"repetitions": 1
}
},
"type": "Foreach"
},
"Get_blob_content": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent('[Some long hash]'))}/content",
"queries": {
"inferContentType": true
}
},
"metadata": {
"[Some long hash]": "/stackoverflow/blob.csv"
},
"runAfter": {
"Get_file_content": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Get_file_content": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['onedriveforbusiness']['connectionId']"
}
},
"method": "get",
"path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent('[Some long hash]'))}/content",
"queries": {
"inferContentType": true
}
},
"metadata": {
"[Some long hash].[Some long hash]": "/LOL/Bok1.csv",
"[Some long hash].[Some long hash]": "/LOL/Bok1.xlsx",
"[Some long hash].[Some long hash]": "/LOL/ReadStuff.csv"
},
"runAfter": {},
"type": "ApiConnection"
},
"Initialize_'data'_string": {
"inputs": {
"variables": [
{
"name": "data",
"type": "String"
}
]
},
"runAfter": {
"Initialize_'tempArray'_array": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_'tempArray'_array": {
"inputs": {
"variables": [
{
"name": "tempArray",
"type": "Array"
}
]
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Month",
"interval": 3
},
"type": "Recurrence"
}
}
}
}