How to download files from OneDrive using SSIS

Introduction

Download File from OneDrive in SSISIn today’s data-driven world, the ability to seamlessly integrate and transfer files between different platforms is crucial for efficient business operations. If you’re a user of SQL Server Integration Services (SSIS) and looking to integrate OneDrive into your data workflow, you’re in luck. ZappySys SSIS PowerPack offers a powerful OneDrive Connector that makes downloading files from OneDrive a breeze. In this guide, we’ll walk you through the process of downloading files from OneDrive using SSIS and the ZappySys SSIS PowerPack OneDrive Connector.

Prerequisites

Before we perform the steps listed in this article, you will need to make sure the following prerequisites are met:
  1. SSIS designer installed. Sometimes it is referred to as BIDS or SSDT (download it from the Microsoft site).
  2. Basic knowledge of SSIS package development using Microsoft SQL Server Integration Services.
  3. Make sure ZappySys SSIS PowerPack is installed (download it, if you haven't already).
  4. (Optional step). Read this article, if you are planning to deploy packages to a server and schedule their execution later.

Download files from OneDrive with SSIS

In this section, we will learn how to configure and use OneDrive Connector in the API Source & API Destination to download files from OneDrive.

  1. Begin with opening Visual Studio and Creating a New Project.
  2. Select Integration Service Project and in the new project window set the appropriate name and location for the project. Click OK.
  3. In the new SSIS project screen you will find the following:
    1. SSIS ToolBox on the left sidebar
    2. Solution Explorer and Property Window on the right bar
    3. Control flow, data flow, event Handlers, Package Explorer in tab windows
    4. Connection Manager Window at the bottom
    zappysys ssis project with toolbox

    SSIS Toolbox – ZappySys Tasks

    NOTE: If you don’t see ZappySys SSIS PowerPack Task or Components in the SSIS Toolbox, please refer to this help link.
  4. Now, Drag and Drop the SSIS Data Flow Task from the SSIS Toolbox. Double-click on the Data Flow Task to see the Data Flow Designer.
  5. From the SSIS toolbox drag and drop API Source (Predefined Templates) on the data flow designer surface, and double-click on it to edit it:
  6. Select New Connection to create a new connection:

Configuring the OneDrive Connector

  1. Use a preinstalled OneDrive Connector from the Popular Connector List or press the Search Online radio button to download OneDrive Connector. Once downloaded simply use it in the configuration:
    ssis onedrive template selection walkthrough
  2. Proceed with selecting the desired Authentication Type. Then select API Base URL (in most cases default one is the right one). Finally, fill in all the required parameters and set optional parameters if needed.
  3. After configuring all the required properties in the API Connection Manager, please click on the “Test Connection” button to confirm that the connection is established successfully.

    Method1: Connect to OneDrive using User Credentials [OAuth]

    You may press a link Steps to Configure which will help set certain parameters.

    SSIS API Source - Generate Token - OneDrive with User Credentials

    SSIS API Source – Generate Token – OneDrive with User Credentials

    Method2: Connect to OneDrive using Application Credentials [OAuth]

    You may press a link Steps to Configure which will help set certain parameters.

    SSIS API Source - Generate Token - OneDrive with Application Credentials

    SSIS API Source – Generate Token – OneDrive with Application Credentials

How to download a single file from OneDrive

In the API Source Component, we’ve chosen the API Connection Manager. Next, we need to configure the remaining properties of the component to download the single file from OneDrive.

  1. Choose the Download file endpoint from the “Select Table/Endpoint” dropdown menu.
  2. Please choose DriveId from the drop-down menu.
  3. Please set the FileId that indicates which file you wish to download. This is an essential parameter for the download process.
  4. Please set the local folder’s physical path which indicates the desired file being downloaded by setting the TargetFilePath parameter.
  5. If you intend to replace the local file with the one being downloaded, please select the ‘AlwaysOverwrite‘ option from the dropdown menu labeled ‘FileOverwriteMode‘. Alternatively, you can choose ‘FileIfExists’ or ‘SkipIfExists’ based on your specific needs.

Please refer to the sample screenshot below.

SSIS API Source - OneDrive - Download Single File

SSIS API Source – OneDrive – Download Single File

Once you have configured all the mentioned properties above, please click on the “Preview Data” button to initiate the API call. With just a few clicks, we have successfully configured the call to OneDrive using the ZappySys OneDrive Connector for downloading a Single file from OneDrive.

How to download multiple files from OneDrive

In the API Destination Component, we have chosen the API Connection Manager. Now, we must proceed to configure the remaining properties of the component to facilitate the download of multiple files from OneDrive. Additionally, we should make use of an OLE DB Source and Derived Column component to map the files for the download process.

  1. Drag and drop the OLE DB Source Component from the SSIS Toolbox. Double-click on the OLE DB Source Component to initiate its configuration.
    OLE DB Source - Drag and Drop

    OLE DB Source – Drag and Drop

  2. Create a new OLE DB Connection Manager and configure your SQL Server settings for the connection. Next, select the Data access mode, specify the name of the table or view, or write an SQL Command. Afterward, click on the ‘Preview’ button to view a preview and check the ‘Columns’ tab for the source columns.
    SSIS OLE DB Source - Configure SQL Connection and fetch the table data

    SSIS OLE DB Source – Configure SQL Connection and fetch the table data

  3. Next, drag and drop the Derived Column Component from the SSIS Toolbox. Double-click on the Derived Column Component to begin its configuration.
    Drag and drop the Derived Column

    Drag and drop the Derived Column

  4. Now, add a new Derived Column by setting the expression to concatenate FilePath and FileName. Click ‘OK’ to save the configuration.
    SSIS Derived Column - Add New Column and Set Expression

    SSIS Derived Column – Add New Column and Set Expression

  5. Now, drag and drop the API Destination Component from the SSIS Toolbox. Double-click on the API Destination Component to begin its configuration.
    Drag and Drop the SSIS API Destination Component

    Drag and Drop the SSIS API Destination Component

  6. Double-click on the API Destination component to configure it for downloading multiple files from OneDrive.
    1. Choose the Download file endpoint from the “Select Table/Endpoint” dropdown menu.
    2. Please specify the ‘FileOverwriteMode’ option as ‘AlwaysOverwrite,’ or you can choose ‘FailIfExists’ or ‘SkipIfExists’ options based on your requirements.
      Please refer to the sample screenshot below.
      SSIS API Destination Component - Configure Settings Tab

      SSIS API Destination Component – Configure Settings Tab

    3. Now, go to the Mappings tab and specify the source columns with the corresponding target properties.
      Note: Here We’re mapping FileID with $$Id and FileNameWithPath with $$ResponseDataFile. You can create mappings based on your Source columns
      Please refer to the sample screenshot below
      SSIS API Destination Component - Configure Mappings Tab

      SSIS API Destination Component – Configure Mappings Tab

  7. Once you have configured all the mentioned properties above, please click on the “Preview Data” button from the Settings tab to initiate the API call. With just a few clicks, we have successfully configured the call to OneDrive using the ZappySys OneDrive Connector for downloading multiple files from OneDrive.
    Please refer to the sample screenshot below.
    Download Multiple files from OneDrive

    Download Multiple files from OneDrive

Conclusion

In this blog, we learned how to connect with OneDrive using SSIS API Connection Manager and download single or multiple files from OneDrive using a combination of SSIS components, including the SSIS API Source component, SSIS API Destination component, OLE DB Source component, and Derived Column component.

Posted in SSIS API Destination, SSIS API Source, SSIS Components, SSIS PowerPack and tagged , , , , , .