-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move-files-to-sharepoint-from-shared-drive
- Loading branch information
Showing
11 changed files
with
360 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
samples/move-file-to-sharepoint-from-shared-drive/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Move files to SharePoint document library from Shared Drive using Power Automate | ||
|
||
## Summary | ||
|
||
This is sample demonstrates how to move recently created files from Shared drive to SharePoint document library. | ||
|
||
![picture of the sample](assets/flow-overview.png) | ||
|
||
## Applies to | ||
|
||
* [Microsoft Power Automate](https://docs.microsoft.com/power-automate/) | ||
|
||
## Compatibility | ||
|
||
> Don't worry about this section, we'll take care of it. Unless you really want to... | ||
![Premium License](https://img.shields.io/badge/Premium%20License-Not%20Required-green.svg "Premium license not required") | ||
![On-Premises Connectors](https://img.shields.io/badge/On--Premises%20Connectors-No-green.svg "Does not use on-premise connectors") | ||
![Custom Connectors](https://img.shields.io/badge/Custom%20Connectors-Not%20Required-green.svg "Does not use custom connectors") | ||
|
||
## Authors | ||
|
||
Solution|Author(s) | ||
--------|--------- | ||
move-files-to-sharepoint-from-shared-drive | [Dinesh Girase](https://github.com/dgirase) ([@dinugirase](https://twitter.com/dinugirase)) | ||
|
||
## Version history | ||
|
||
Version|Date|Comments | ||
-------|----|-------- | ||
1.0|October 25, 2025|Initial release | ||
|
||
## Features | ||
|
||
This sample demonstrates the following concepts: | ||
|
||
* Triggerd the power automate when file gets created on shared drive (physical location) | ||
* Get the file content using file Id. | ||
* Create a actual file in SharePoint document library. | ||
* Delete the file from Shared Drive (physical location). | ||
|
||
## Prerequisites | ||
|
||
[Download and Install](https://learn.microsoft.com/en-us/data-integration/gateway/service-gateway-install) on-premises data gateway on Virtual Machine where the shared drive is accessible. The on-premises data gateway acts as a bridge. It provides quick and secure data transfer between on-premises data, which is data that isn't in the cloud, and several Microsoft cloud services. | ||
|
||
## Minimal Path to Awesome | ||
|
||
* [Download](solution/movefiletosharepointfromshareddrive.zip) the `.zip` from the `solution` folder | ||
* [Install](https://learn.microsoft.com/en-us/data-integration/gateway/service-gateway-install) the on-premises data gateway. | ||
* Browse to [Power Automate Portal](https://make.powerautomate.com) and select the environment you want to import the sample to | ||
* [Import](https://flow.microsoft.com/en-us/blog/import-export-bap-packages/) the `.zip` file using **My Flows** > **Import** > **Upload** within Microsoft Flow. | ||
* Change and configure the connection for file system. | ||
|
||
## Disclaimer | ||
|
||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** | ||
|
||
## Help | ||
|
||
> Note: don't worry about this section, we'll update the links. | ||
We do not support samples, but we this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues. | ||
|
||
If you encounter any issues while using this sample, [create a new issue](https://github.com/pnp/powerautomate-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=YOURSAMPLENAME&authors=@YOURGITHUBUSERNAME&title=YOURSAMPLENAME%20-%20). | ||
|
||
For questions regarding this sample, [create a new question](https://github.com/pnp/powerautomate-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=YOURSAMPLENAME&authors=@YOURGITHUBUSERNAME&title=YOURSAMPLENAME%20-%20). | ||
|
||
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/powerautomate-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=YOURSAMPLENAME&authors=@YOURGITHUBUSERNAME&title=YOURSAMPLENAME%20-%20). | ||
|
||
## For more information | ||
|
||
- [Create your first flow](https://docs.microsoft.com/en-us/power-automate/getting-started#create-your-first-flow) | ||
- [Microsoft Power Automate documentation](https://docs.microsoft.com/en-us/power-automate/) | ||
|
||
|
||
<img src="https://telemetry.sharepointpnp.com/powerautomate-samples/samples/readme-template" /> | ||
|
||
--- |
Binary file added
BIN
+18.8 KB
samples/move-file-to-sharepoint-from-shared-drive/assets/each-file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.07 KB
samples/move-file-to-sharepoint-from-shared-drive/assets/file-created-trigger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18 KB
...les/move-file-to-sharepoint-from-shared-drive/assets/file-system-connection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+15.5 KB
samples/move-file-to-sharepoint-from-shared-drive/assets/flow-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.24 KB
...ove-file-to-sharepoint-from-shared-drive/solution/movefiletosharepointfromshareddrive.zip
Binary file not shown.
1 change: 1 addition & 0 deletions
1
...d-drive/sourcecode/Microsoft.Flow/flows/f702ab78-02f3-4713-9fea-2b7bbe3ac59d/apisMap.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"shared_filesystem":"68d594b2-c9da-48aa-bca4-b6f4dc7f602f","shared_sharepointonline_1":"32e1fc5c-5601-4eb7-a33e-4e2e23817c17"} |
1 change: 1 addition & 0 deletions
1
.../sourcecode/Microsoft.Flow/flows/f702ab78-02f3-4713-9fea-2b7bbe3ac59d/connectionsMap.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"shared_filesystem":"2d2a70d3-e1b5-4973-837e-e76a98b42b83","shared_sharepointonline_1":"165a6813-2185-4c58-a8ab-d3acbeec32e1"} |
196 changes: 196 additions & 0 deletions
196
...rive/sourcecode/Microsoft.Flow/flows/f702ab78-02f3-4713-9fea-2b7bbe3ac59d/definition.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
{ | ||
"name": "eb363614-010c-4115-b7f2-f6a4d17504e1", | ||
"id": "/providers/Microsoft.Flow/flows/eb363614-010c-4115-b7f2-f6a4d17504e1", | ||
"type": "Microsoft.Flow/flows", | ||
"properties": { | ||
"apiId": "/providers/Microsoft.PowerApps/apis/shared_logicflows", | ||
"displayName": "Move file to SharePoint from Shared Drive", | ||
"definition": { | ||
"metadata": { | ||
"workflowEntityId": null, | ||
"processAdvisorMetadata": null, | ||
"flowChargedByPaygo": null, | ||
"flowclientsuspensionreason": "None", | ||
"flowclientsuspensiontime": null, | ||
"flowclientsuspensionreasondetails": null, | ||
"creator": { | ||
"id": "1f4d8f35-7a35-4146-9a02-c579e47041a8", | ||
"type": "User", | ||
"tenantId": "ee560e77-afeb-419b-8b24-043d8da097a2" | ||
}, | ||
"provisioningMethod": "FromDefinition", | ||
"failureAlertSubscription": true, | ||
"clientLastModifiedTime": "2023-10-25T11:53:27.6979027Z" | ||
}, | ||
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"$connections": { | ||
"defaultValue": {}, | ||
"type": "Object" | ||
}, | ||
"$authentication": { | ||
"defaultValue": {}, | ||
"type": "SecureObject" | ||
} | ||
}, | ||
"triggers": { | ||
"When_a_file_is_created_(properties_only)": { | ||
"recurrence": { | ||
"frequency": "Minute", | ||
"interval": 5 | ||
}, | ||
"metadata": { | ||
"XFxrcmwtZnMwM1xJbnZvaWNlc1xQcm9k": "\\\\sharedDrive\\folder", | ||
"operationMetadataId": "8e0b0f84-fa31-4552-94ce-6ad1f0451f1d", | ||
"flowSystemMetadata": { | ||
"swaggerOperationId": "OnNewFiles" | ||
}, | ||
"XFxrcmwtZnMwM1xJbnZvaWNlc1xVQVQ=": "\\\\sharedDrive\\folder" | ||
}, | ||
"type": "ApiConnection", | ||
"inputs": { | ||
"host": { | ||
"connection": { | ||
"name": "@parameters('$connections')['shared_filesystem']['connectionId']" | ||
}, | ||
"api": { | ||
"runtimeUrl": "https://flow-apim-msmanaged-na-northcentralus-01.azure-apim.net/apim/filesystem" | ||
} | ||
}, | ||
"method": "get", | ||
"path": "/datasets/default/triggers/batch/onnewfile", | ||
"queries": { | ||
"folderId": "\\\\sharedDrive\\folder", | ||
"maxFileCount": 1 | ||
}, | ||
"authentication": "@parameters('$authentication')" | ||
} | ||
} | ||
}, | ||
"actions": { | ||
"Each_file": { | ||
"foreach": "@triggerBody()", | ||
"actions": { | ||
"Get_file_content_from_Shared_Drive": { | ||
"runAfter": {}, | ||
"metadata": { | ||
"operationMetadataId": "2067e2ae-cb1e-4b70-a6d4-192e57717142", | ||
"flowSystemMetadata": { | ||
"swaggerOperationId": "GetFileContent" | ||
} | ||
}, | ||
"type": "ApiConnection", | ||
"inputs": { | ||
"host": { | ||
"connection": { | ||
"name": "@parameters('$connections')['shared_filesystem']['connectionId']" | ||
}, | ||
"api": { | ||
"runtimeUrl": "https://flow-apim-msmanaged-na-northcentralus-01.azure-apim.net/apim/filesystem" | ||
} | ||
}, | ||
"method": "get", | ||
"path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(items('Each_file')?['Id']))}/content", | ||
"queries": { | ||
"inferContentType": true | ||
}, | ||
"authentication": "@parameters('$authentication')" | ||
} | ||
}, | ||
"Move_file_to_SharePoint_Document_Library": { | ||
"runAfter": { | ||
"Get_file_content_from_Shared_Drive": [ | ||
"Succeeded" | ||
] | ||
}, | ||
"metadata": { | ||
"operationMetadataId": "f8b63710-8b91-4bb0-8283-afe3e7248db5", | ||
"flowSystemMetadata": { | ||
"swaggerOperationId": "CreateFile" | ||
} | ||
}, | ||
"type": "ApiConnection", | ||
"inputs": { | ||
"host": { | ||
"connection": { | ||
"name": "@parameters('$connections')['shared_sharepointonline_1']['connectionId']" | ||
}, | ||
"api": { | ||
"runtimeUrl": "https://flow-apim-msmanaged-na-eastus-01.azure-apim.net/apim/sharepointonline" | ||
} | ||
}, | ||
"method": "post", | ||
"body": "@body('Get_file_content_from_Shared_Drive')", | ||
"path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://dphasis.sharepoint.com/sites/Samples'))}/files", | ||
"queries": { | ||
"folderPath": "/Shared Documents", | ||
"name": "@items('Each_file')?['Name']", | ||
"queryParametersSingleEncoded": true | ||
}, | ||
"authentication": "@parameters('$authentication')" | ||
}, | ||
"runtimeConfiguration": { | ||
"contentTransfer": { | ||
"transferMode": "Chunked" | ||
} | ||
} | ||
}, | ||
"Delete_file_of_Shared_Drive": { | ||
"runAfter": { | ||
"Move_file_to_SharePoint_Document_Library": [ | ||
"Succeeded" | ||
] | ||
}, | ||
"metadata": { | ||
"operationMetadataId": "22329b06-faa0-40c2-8e8e-b0e0d9c0a629", | ||
"flowSystemMetadata": { | ||
"swaggerOperationId": "DeleteFile" | ||
} | ||
}, | ||
"type": "ApiConnection", | ||
"inputs": { | ||
"host": { | ||
"connection": { | ||
"name": "@parameters('$connections')['shared_filesystem']['connectionId']" | ||
}, | ||
"api": { | ||
"runtimeUrl": "https://flow-apim-msmanaged-na-northcentralus-01.azure-apim.net/apim/filesystem" | ||
} | ||
}, | ||
"method": "delete", | ||
"headers": { | ||
"SkipDeleteIfFileNotFoundOnServer": false | ||
}, | ||
"path": "/datasets/default/files/@{encodeURIComponent(encodeURIComponent(items('Each_file')?['Id']))}", | ||
"authentication": "@parameters('$authentication')" | ||
} | ||
} | ||
}, | ||
"runAfter": {}, | ||
"metadata": { | ||
"operationMetadataId": "05421767-bdb5-4775-b06e-001fbfd46c2f" | ||
}, | ||
"type": "Foreach" | ||
} | ||
}, | ||
"outputs": {} | ||
}, | ||
"connectionReferences": { | ||
"shared_filesystem": { | ||
"connectionName": "shared-filesystem-97f717ca-eec5-48f7-96d5-6552c50bc2ac", | ||
"source": "Embedded", | ||
"id": "/providers/Microsoft.PowerApps/apis/shared_filesystem", | ||
"tier": "NotSpecified" | ||
}, | ||
"shared_sharepointonline_1": { | ||
"connectionName": "shared-sharepointonl-e69b4628-d9d4-488c-9dbe-6bdd72bae4e4", | ||
"source": "Embedded", | ||
"id": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline", | ||
"tier": "NotSpecified" | ||
} | ||
}, | ||
"flowFailureAlertSubscribed": false, | ||
"isManaged": false | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...s/move-file-to-sharepoint-from-shared-drive/sourcecode/Microsoft.Flow/flows/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"packageSchemaVersion":"1.0","flowAssets":{"assetPaths":["f702ab78-02f3-4713-9fea-2b7bbe3ac59d"]}} |
83 changes: 83 additions & 0 deletions
83
samples/move-file-to-sharepoint-from-shared-drive/sourcecode/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"schema": "1.0", | ||
"details": { | ||
"displayName": "move-file-to-sharepoint-from-shared-drive", | ||
"description": "", | ||
"createdTime": "2023-10-25T11:55:11.4908059Z", | ||
"packageTelemetryId": "e29b4cc3-4501-45a4-9d82-f8ef73c545c8", | ||
"creator": "N/A", | ||
"sourceEnvironment": "" | ||
}, | ||
"resources": { | ||
"f702ab78-02f3-4713-9fea-2b7bbe3ac59d": { | ||
"type": "Microsoft.Flow/flows", | ||
"suggestedCreationType": "Update", | ||
"creationType": "Existing, New, Update", | ||
"details": { | ||
"displayName": "Move file to SharePoint from Shared Drive" | ||
}, | ||
"configurableBy": "User", | ||
"hierarchy": "Root", | ||
"dependsOn": [ | ||
"68d594b2-c9da-48aa-bca4-b6f4dc7f602f", | ||
"2d2a70d3-e1b5-4973-837e-e76a98b42b83", | ||
"32e1fc5c-5601-4eb7-a33e-4e2e23817c17", | ||
"165a6813-2185-4c58-a8ab-d3acbeec32e1" | ||
] | ||
}, | ||
"68d594b2-c9da-48aa-bca4-b6f4dc7f602f": { | ||
"id": "/providers/Microsoft.PowerApps/apis/shared_filesystem", | ||
"name": "shared_filesystem", | ||
"type": "Microsoft.PowerApps/apis", | ||
"suggestedCreationType": "Existing", | ||
"details": { | ||
"displayName": "File System", | ||
"iconUri": "https://connectoricons-prod.azureedge.net/releases/v1.0.1654/1.0.1654.3414/filesystem/icon.png" | ||
}, | ||
"configurableBy": "System", | ||
"hierarchy": "Child", | ||
"dependsOn": [] | ||
}, | ||
"2d2a70d3-e1b5-4973-837e-e76a98b42b83": { | ||
"type": "Microsoft.PowerApps/apis/connections", | ||
"suggestedCreationType": "Existing", | ||
"creationType": "Existing", | ||
"details": { | ||
"displayName": "On-Premises-Shared-Drive-Documents", | ||
"iconUri": "https://connectoricons-prod.azureedge.net/releases/v1.0.1625/1.0.1625.3226/filesystem/icon.png" | ||
}, | ||
"configurableBy": "User", | ||
"hierarchy": "Child", | ||
"dependsOn": [ | ||
"68d594b2-c9da-48aa-bca4-b6f4dc7f602f" | ||
] | ||
}, | ||
"32e1fc5c-5601-4eb7-a33e-4e2e23817c17": { | ||
"id": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline", | ||
"name": "shared_sharepointonline", | ||
"type": "Microsoft.PowerApps/apis", | ||
"suggestedCreationType": "Existing", | ||
"details": { | ||
"displayName": "SharePoint", | ||
"iconUri": "https://connectoricons-prod.azureedge.net/releases/v1.0.1656/1.0.1656.3432/sharepointonline/icon.png" | ||
}, | ||
"configurableBy": "System", | ||
"hierarchy": "Child", | ||
"dependsOn": [] | ||
}, | ||
"165a6813-2185-4c58-a8ab-d3acbeec32e1": { | ||
"type": "Microsoft.PowerApps/apis/connections", | ||
"suggestedCreationType": "Existing", | ||
"creationType": "Existing", | ||
"details": { | ||
"displayName": "[email protected]", | ||
"iconUri": "https://connectoricons-prod.azureedge.net/releases/v1.0.1623/1.0.1623.3210/sharepointonline/icon.png" | ||
}, | ||
"configurableBy": "User", | ||
"hierarchy": "Child", | ||
"dependsOn": [ | ||
"32e1fc5c-5601-4eb7-a33e-4e2e23817c17" | ||
] | ||
} | ||
} | ||
} |