|
| 1 | +# Move files from a SharePoint site to Azure File Storage |
| 2 | + |
| 3 | +Costa Rica |
| 4 | + |
| 5 | +[](https://github.com) |
| 6 | +[](https://github.com/) |
| 7 | +[brown9804](https://github.com/brown9804) |
| 8 | + |
| 9 | +Last updated: 2024-11-19 |
| 10 | + |
| 11 | +---------- |
| 12 | + |
| 13 | +There might be few ways to do it: |
| 14 | + |
| 15 | +- Using Az Copy |
| 16 | +- Using Data Factory |
| 17 | +- Using Logic App |
| 18 | + |
| 19 | +## Wiki |
| 20 | + |
| 21 | +- [Tutorial: Migrate on-premises data to cloud storage with AzCopy](https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-migrate-on-premises-data?tabs=windows) |
| 22 | +- [Move files from a SharePoint site to Azure File Storage](https://learn.microsoft.com/en-us/answers/questions/1382373/move-files-from-a-sharepoint-site-to-azure-file-st) |
| 23 | +- [Copy data from SharePoint Online List by using Azure Data Factory or Azure Synapse Analytics](https://learn.microsoft.com/en-us/azure/data-factory/connector-sharepoint-online-list?tabs=data-factory) |
| 24 | + |
| 25 | +## Using AzCopy |
| 26 | + |
| 27 | +1. **Set Up Azure Storage**: |
| 28 | + - Create a storage account in Azure if you don't have one. |
| 29 | + - Create a container within the storage account to store your files. |
| 30 | +2. **Authenticate with Microsoft Entra ID**: |
| 31 | + - Download and install AzCopy, a command-line tool for copying data to Azure Storage. |
| 32 | + - Authenticate using Microsoft Entra ID with the command: |
| 33 | + |
| 34 | + ```bash |
| 35 | + azcopy login --tenant-id <your-tenant-id> |
| 36 | + ``` |
| 37 | + |
| 38 | +3. **Move Files from SharePoint to Azure Storage**: |
| 39 | + - Sync the SharePoint files to your local PC. |
| 40 | + - Use AzCopy to copy the files from your local PC to the Azure Storage container: |
| 41 | + |
| 42 | + ```bash |
| 43 | + azcopy copy "C:\path\to\your\folder" "https://<your-account>.blob.core.windows.net/<your-container>" --recursive |
| 44 | + ``` |
| 45 | + |
| 46 | +4. **Automation**: You can create scripts or use tools like Power Automate to automate the file copying process. |
| 47 | + |
| 48 | +## Using Data Factory |
| 49 | + |
| 50 | +Initial Setup: |
| 51 | + |
| 52 | +1. **Register an Application in Azure AD**: |
| 53 | + - Go to the Azure portal and navigate to `Azure Active Directory`. |
| 54 | + - Register a new application and note down the `Application ID` and `Client Secret`. |
| 55 | +2. **Configure Permissions in SharePoint**: Grant the registered application permissions to access SharePoint files. |
| 56 | + |
| 57 | +Create a Pipeline in Azure Data Factory: |
| 58 | + |
| 59 | +1. **Create a Linked Service for SharePoint**: |
| 60 | + - In Azure Data Factory, go to the `Manage` section and select `Linked Services`. |
| 61 | + - Create a new Linked Service for SharePoint Online List and configure the connection details using the Application ID and Client Secret. |
| 62 | +2. **Create a Linked Service for Azure Blob Storage**: Create another Linked Service for your Azure Blob Storage account. |
| 63 | +3. **Configure the Pipeline**: |
| 64 | + - Create a new pipeline and add a `Web Activity` to get an access token from SharePoint. |
| 65 | + - Add another `Web Activity` to get the metadata of the SharePoint folder. |
| 66 | + - Use a `ForEach Activity` to iterate over the files obtained. |
| 67 | + - Inside the ForEach, add a `Copy Data Activity` to copy the files from SharePoint to Azure Blob Storage. |
| 68 | +
|
| 69 | +Configuration Details |
| 70 | +
|
| 71 | +- **Web Activity to Get the Token**: |
| 72 | +
|
| 73 | + ```json |
| 74 | + { |
| 75 | + "url": "https://accounts.accesscontrol.windows.net/<tenant-id>/tokens/OAuth/2", |
| 76 | + "method": "POST", |
| 77 | + "headers": { |
| 78 | + "Content-Type": "application/x-www-form-urlencoded" |
| 79 | + }, |
| 80 | + "body": "grant_type=client_credentials&client_id=<client-id>&client_secret=<client-secret>&resource=https://<sharepoint-site>" |
| 81 | + } |
| 82 | + ``` |
| 83 | +
|
| 84 | +- **Web Activity to Get Metadata**: |
| 85 | +
|
| 86 | + ```json |
| 87 | + { |
| 88 | + "url": "https://<sharepoint-site>/_api/web/GetFolderByServerRelativeUrl('<folder-path>')/Files", |
| 89 | + "method": "GET", |
| 90 | + "headers": { |
| 91 | + "Authorization": "Bearer <access-token>" |
| 92 | + } |
| 93 | + } |
| 94 | + ``` |
| 95 | +
|
| 96 | +- **Copy Data Activity**: |
| 97 | + - Configure the source as SharePoint and the destination as Azure Blob Storage. |
| 98 | + - Map the necessary fields to copy the files. |
| 99 | +
|
| 100 | +Testing and Automation: |
| 101 | +- **Test the Pipeline**: Run the pipeline to ensure the files are copied correctly. |
| 102 | +- **Automate**: Schedule the pipeline to run at regular intervals or in response to specific events. |
| 103 | +
|
| 104 | +
|
| 105 | +
|
| 106 | +
|
| 107 | +## Using Azure Logic Apps |
| 108 | +
|
| 109 | +1. **Create a Logic App**: |
| 110 | + - In the Azure portal, create a new Logic App. |
| 111 | + - Choose a blank template to start from scratch. |
| 112 | +2. **Configure the Trigger**: |
| 113 | + - Add a SharePoint trigger, such as `When a file is created in a folder`. |
| 114 | + - Connect to your SharePoint site and select the folder you want to monitor. |
| 115 | +3. **Add an Action to Copy Files**: |
| 116 | + - Add an Azure Blob Storage action, such as `Create blob`. |
| 117 | + - Connect to your Azure Storage account and select the destination container. |
| 118 | +4. **Map the Data**: Map the file data from SharePoint to the corresponding fields in Azure Blob Storage. |
| 119 | +5. **Save and Test**: Save the Logic App and test it by creating a file in the SharePoint folder to ensure it gets copied to Azure Storage. |
| 120 | +
|
| 121 | +<div align="center"> |
| 122 | + <h3 style="color: #4CAF50;">Total Visitors</h3> |
| 123 | + <img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/> |
| 124 | +</div> |
0 commit comments