使用逻辑应用将文件 - SharePoint 数据复制到 Azure Blob

问题描述 投票:0回答:1

我有一个场景,其中共享点中有多个父文件夹,这些文件夹包含多个嵌套或子文件夹,然后有一个文件。我如何通过使用 Logic 应用程序维护 Sharepoint 中相同的文件夹结构来将这些文件复制到 blob。

azure-logic-apps azure-logic-app-standard
1个回答
0
投票

我在 SharePoint 的

Test/demo/demo1
文件夹中有文件。

enter image description here

我正在使用以下工作流程通过保持文件夹结构完整来将这些文件复制到 Blob 存储。

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

代码-

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "For_each": {
                "actions": {
                    "Create_blob_(V2)": {
                        "inputs": {
                            "body": "@body('Get_file_content_using_path')",
                            "headers": {
                                "ReadFileMetadataFromServer": true
                            },
                            "host": {
                                "connection": {
                                    "referenceName": "azureblob"
                                }
                            },
                            "method": "post",
                            "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files",
                            "queries": {
                                "folderPath": "/samples-workitems",
                                "name": "@items('For_each')?['Path']",
                                "queryParametersSingleEncoded": true
                            }
                        },
                        "runAfter": {
                            "Get_file_content_using_path": [
                                "SUCCEEDED"
                            ]
                        },
                        "runtimeConfiguration": {
                            "contentTransfer": {
                                "transferMode": "Chunked"
                            }
                        },
                        "type": "ApiConnection"
                    },
                    "Get_file_content_using_path": {
                        "inputs": {
                            "host": {
                                "connection": {
                                    "referenceName": "sharepointonline"
                                }
                            },
                            "method": "get",
                            "path": "/datasets/@{encodeURIComponent(encodeURIComponent('**********'))}/GetFileContentByPath",
                            "queries": {
                                "inferContentType": true,
                                "path": "@items('For_each')?['Path']",
                                "queryParametersSingleEncoded": true
                            }
                        },
                        "type": "ApiConnection"
                    }
                },
                "foreach": "@body('List_folder')",
                "runAfter": {
                    "List_folder": [
                        "SUCCEEDED"
                    ]
                },
                "type": "Foreach"
            },
            "List_folder": {
                "inputs": {
                    "host": {
                        "connection": {
                            "referenceName": "sharepointonline"
                        }
                    },
                    "method": "get",
                    "path": "/datasets/@{encodeURIComponent(encodeURIComponent('*********'))}/folders/@{encodeURIComponent('%252fTest%252fdemo%252fdemo1')}"
                },
                "metadata": {
                    "%252fTest": "/Test",
                    "%252fTest%252fdemo%252fdemo1": "/Test/demo/demo1"
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "triggers": {
            "When_a_HTTP_request_is_received": {
                "kind": "Http",
                "runtimeConfiguration": {
                    "concurrency": {
                        "runs": 1
                    }
                },
                "type": "Request"
            }
        }
    },
    "kind": "Stateful"
}

输出-

enter image description here

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.