How to upload Files in Azure File Shares (not Blob Storage)

This article explains how to upload files in Azure File Shares (not Blob Storage) using the ZappySys REST API Task in SSIS. It also covers how to generate SAS tokens and construct the appropriate REST API URL for accessing the files.

What is Azure Files?

Azure Files offers fully managed file shares in the cloud that are accessible via the industry standard Server Message Block (SMB) protocol, Network File System (NFS) protocol, and Azure Files REST API. Azure file shares can be mounted concurrently by cloud or on-premises deployments. SMB Azure file shares are accessible from Windows, Linux, and macOS clients. NFS Azure file shares are accessible from Linux clients. Additionally, SMB Azure file shares can be cached on Windows servers with Azure File Sync for fast access near where the data is being used.

Prerequisites

  • SSIS installed
  • Download and install the ZappySys SSIS PowerPack.
  • Azure Storage account with a File Share created

Generate SAS Token for Azure File Share

To authenticate REST API requests, generate a Shared Access Signature (SAS) token with required permissions.

Steps:

  1. Go to Azure Portal > Storage Accounts > [Your Account] > File shares.
  2. Click Shared access signature in the left menu.
  3. Select:
    • Allowed services: File
    • Allowed resource types: Service, Container, Object
    • Allowed permissions: Read, Write, List, Create, Delete
  4. Set expiry time (UTC).
  5. Click Generate SAS and connection string.
  6. Copy the SAS Token (starting with ?sv=...).

Build Azure File Share REST API URL

To upload a file, construct the REST API URL using the storage account name <storage-account-name>, file share <share-name>, file path <directory>, file name <file-name>, and SAS token <sas-token>. This URL is used in the ZappySys REST API Task to perform a GET request and retrieve the file from Azure File Share to your local system.

Format:

  1. To create the file placeholder
    https://<storage-account-name>.file.core.windows.net/<share-name>/<directory>/<file-name>?<sas-token>
    
  2. To upload the file content using a range PUT
    https://<storage-account-name>.file.core.windows.net/<share-name>/<directory>/<file-name>?comp=range&<sas-token>
    

Example:

  1. To create the file placeholder:
    https://mystorageacct.file.core.windows.net/myshare/dir1/myfile.zip?<sas-token>
    
  2. To upload the file content using a range PUT
    https://mystorageacct.file.core.windows.net/myshare/dir1/myfile.zip?comp=range&<sas-token>
    

Upload File in Azure File Share

To upload a file to Azure File Share using ZappySys REST API Task, you need to first create the file on Azure and then write the file content using a range-based PUT request. By using SSIS variables, you can dynamically build the target path, file name, and authentication token, making your upload process flexible and reusable.

Let’s Create Required SSIS Variables

Before we upload the file from Azure File Share, let’s define a few SSIS variables to store the storage account name, file path, file name, and SAS token. These variables will help us build the upload URL dynamically and make the package more flexible and reusable. In your SSIS package, create the following variables:

Variable Name Type Example Value
AzureStorageAccount String mystorageacct
FileShareName String myshare
AzureFilePath String reports/sales-report.zip
SASToken String sv=2024-08-04&st=2025-05-05&se=xx&sr=s&sp=rl&...
LocalFilePath String C:\SSIS\Uploads\sales-report.zip

Uploading Files using ZappySys REST API Task

Uploading a file to Azure File Share using ZappySys involves two main REST calls:

  1. Create the file placeholder
  2. Upload the file content using a range PUT

We’ll use SSIS variables to construct the file path and pass the SAS token dynamically.

Step-1: Add a Sequence Container

  1. In the Control Flow tab, drag a Sequence Container.

  2. Rename it: Upload File to Azure (optional)

  3. Inside the Sequence Container (named Upload File to Azure), you’ll need to add two ZappySys REST API Tasks — one to create the file and one to upload the file content.

    :arrow_right: In the next section, we’ll show you how to drag and drop the REST API tasks and configure each one with the correct URL, headers, and file options.

Step-2: Create File in Azure File Share (Initial PUT)

  1. Inside the Sequence Container (named Upload File to Azure), Drag and drop REST API Task from the SSIS Toolbox into the Control Flow.

  2. Rename it to: Step-1 Create File (with meta) (optional)

  3. Double-click the task to open its editor.

  4. In the ZappySys REST API Task, set the following:
    4.1 Access Mode: Direct URL
    4.2 Web URL: Set to the variable-based dynamic URL

    https://{{User::AzureStorageAccount}}.file.core.windows.net/{{User::FileShareName}}/{{User::AzureFilePath}}?{{User::SASToken}}
    

    4.3 HTTP Request Method: PUT

    Please refer to the steps shown in the image below for guidance.
    For guidance on creating a dynamic URL in your API calls, please refer to this article: How to make Path / URL dynamic in SSIS

  5. Here’s how to set the required HTTP headers in the ZappySys REST API Task when uploading a file to Azure File Share, using dynamic values for file size, creation time, and last modified time based on the local file (User::LocalFilePath):

    Go to the HTTP Headers section, remove all default headers, and add the following header.
    For more details, you can refer to this help link: Azure Files REST API

    Required HTTP Headers (for File Creation Request)

    Header Name Value
    x-ms-type file
    x-ms-content-length <<{{User::LocalFilePath}},FUN_FILE_SIZE>>
    x-ms-version 2025-05-05
    x-ms-file-attributes Archive
    x-ms-file-permission inherit
    x-ms-file-creation-time <<{{User::LocalFilePath}},FUN_FILE_CREATE_DATE>>0000Z
    x-ms-file-last-write-time <<{{User::LocalFilePath}},FUN_FILE_LASTEDIT_DATE>>0000Z

    Explanation of Placeholders

    These special functions are supported by ZappySys REST API Task to extract file metadata automatically at runtime. For more details, you can refer to this help link: Format Specifiers / Placeholder Functions

    • <<{{User::LocalFilePath}},FUN_FILE_SIZE>>: Gets the file size in bytes
    • <<{{User::LocalFilePath}},FUN_FILE_CREATE_DATE>>: Gets file creation time in ISO format (e.g. 2024-12-01T10:23:00)
    • <<{{User::LocalFilePath}},FUN_FILE_LASTEDIT_DATE>>: Gets last modified time in ISO format
    • Append 0000Z to match Azure File Share timestamp formatting

  6. No request body is needed for this step.

  7. That’s it! Click OK to save the settings.

Step-3: Upload File Content in Azure File Share (PUT with Range)

  1. Inside the Sequence Container (named Upload File to Azure), Drag and drop another REST API Task.

  2. Rename it to: Step-2 Upload File Data (optional)

  3. Double-click the task to open its editor.

  4. In the ZappySys REST API Task, set the following:

    4.1 Access Mode: Direct URL

    4.2 Web URL: Set to the variable-based dynamic URL

    https://{{User::AzureStorageAccount}}.file.core.windows.net/{{User::FileShareName}}/{{User::AzureFilePath}}?comp=range&{{User::SASToken}}
    

    4.3 HTTP Request Method: PUT

    4.4 Body: @{{User::LocalFilePath}}
    ZappySys will automatically read the file specified in the variable User::LocalFilePath and stream it to Azure as part of the PUT request.

    4.5 Check File Upload / Multi part
    Enable this option to indicate that the request body contains a binary data.

    4.6 Go to the HTTP Headers section, remove all default headers, and add the following header. For more details, you can refer to this help link: Azure Files REST API

    Required HTTP Headers (for File Creation Request)

    Header Name Value
    x-ms-version 2025-05-05
    x-ms-write update

    Please refer to the steps shown in the image below for guidance.

  5. Azure File Share requires that file data be uploaded in chunks of up to 4 MiB (4,194,304 bytes) per request. To configure this in ZappySys REST API Task:

    5.1 Go to the Large File Upload tab
    5.2 Enable very large upload using content-range (chunked upload)
    5.3 Set Chunk Size (Bytes) to 4194304 (i.e., 4 MiB)
    5.4 Set Range Header Name to x-ms-range
    5.5 Set Range Header Value Template to:

    bytes={next-range-start}-{next-range-end}
    

    This ensures the file is broken into proper chunks and sent with the required Azure range format during upload.

  6. That’s it! Click OK to save the settings.

Once all tasks are configured, execute the SSIS package. This will trigger the REST API calls to first create the file and then upload its contents to the specified Azure File Share path. If successful, your file should appear in the target directory with correct metadata and content.

Related: How to Download Files from Azure File Shares

If you’re looking to download files instead of uploading, check out our companion guide:
https://community.zappysys.com/t/how-to-download-files-from-azure-file-shares-not-blob-storage/530

References

Conclusion

In this guide, we’ve walked through the steps to upload files in Azure File Shares using the ZappySys REST API Task in SSIS. By leveraging SSIS variables, chunked upload settings, and proper HTTP headers, you can handle large files efficiently and ensure Azure requirements are met. This method is ideal for integrating cloud file operations into your ETL workflows with full control and reliability.