我们的SharePoint在线存储已满,在SharePoint在线上购买额外的存储空间非常昂贵。我想要将文件夹从 SharePoint Online 复制到 Azure Blob 或 Azure 文件共享冷访问层作为存储存档。我尝试使用电源自动化和逻辑应用程序,它只是为新创建的文件创建规则,但没有选项来移动已创建的 Sharepoint 在线文件夹。请告诉我任何步骤或建议。
以下是我实现您的要求所遵循的流程。
首先,我尝试使用共享点的
List folder
操作列出所需文件夹内的文件,这使我可以选择取消特定文件的文件标识符。
在下一步中,我尝试在上一步中提到的文件夹内循环,以使用
Get file metadata
操作检索文件的元数据,并使用共享点的 Get file content
操作获取文件的内容。
在下一步中,我使用 Azure Blob 存储的
Create blob (V2)
操作,使用来自共享点的文件内容和文件元数据在存储内创建 Blob。
此步骤不是必需的,但如果您想自动删除共享点中的所有文件,您可以使用共享点的
Delete file
操作来删除已复制到共享点的文件。
下面是我的逻辑应用程序的整个流程
结果:
以下是我的 Sharepoint 站点中已存在的文件:-
在我的存储帐户中
注意: 如果您尝试自动从共享点删除文件,请确保文件首先从共享点移动到 Blob 存储(即,不使用删除文件操作),然后在传输完成后尝试使用删除 blob 操作创建新流程来删除文件。
要在逻辑应用程序中重现相同的内容,您可以使用以下代码视图。
{
"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')",
"headers": {
"ReadFileMetadataFromServer": true
},
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "post",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files",
"queries": {
"folderPath": "/container",
"name": "@body('Get_file_metadata')?['DisplayName']",
"queryParametersSingleEncoded": true
}
},
"runAfter": {
"Get_file_content": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
},
"type": "ApiConnection"
},
"Get_file_content": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "get",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('<SITE_URL>'))}/files/@{encodeURIComponent(items('For_each')?['Id'])}/content",
"queries": {
"inferContentType": true
}
},
"runAfter": {
"Get_file_metadata": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Get_file_metadata": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "get",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('<SITE_URL>'))}/files/@{encodeURIComponent(items('For_each')?['Id'])}"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"foreach": "@body('List_folder')",
"runAfter": {
"List_folder": [
"Succeeded"
]
},
"type": "Foreach"
},
"List_folder": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['sharepointonline']['connectionId']"
}
},
"method": "get",
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('<SITE_URL>'))}/folders/@{encodeURIComponent('%252fShared%2bDocuments')}"
},
"metadata": {
"%252fShared%2bDocuments": "/Shared Documents"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/<SUB_ID>/resourceGroups/<RG>/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/<SUB_ID>/providers/Microsoft.Web/locations/centralus/managedApis/azureblob"
},
"sharepointonline": {
"connectionId": "/subscriptions/<SUB_ID>/resourceGroups/<RG>/providers/Microsoft.Web/connections/sharepointonline",
"connectionName": "sharepointonline",
"id": "/subscriptions/<SUB_ID>/providers/Microsoft.Web/locations/centralus/managedApis/sharepointonline"
}
}
}
}
}