Forum Discussion

velmars's avatar
velmars
Copper Contributor
Jul 25, 2025

Azure function app to read files from SMB mounted file share

How can I programmatically connect an Azure Function App to multiple (50+) SMB-mounted Azure File Shares that use the same credentials, given that Logic Apps aren't suitable due to their static connection requirements?

1 Reply

  • Take this:

     

    What you required:

    • Linux Function App: SMB mounting is supported only on Linux-based Function Apps.
    • Azure Files: Ensure each file share is created in Azure Storage.
    • Same Credentials: Use the same storage account access key across all mounts.

     

    Steps:

     

    1. Use Azure CLI to Mount Each Share

    You can mount each file share using az webapp config storage-account add:

    az webapp config storage-account add \
      --resource-group <your-resource-group> \
      --name <your-function-app-name> \
      --custom-id <unique-id-for-this-share> \
      --storage-type AzureFiles \
      --account-name <storage-account-name> \
      --share-name <file-share-name> \
      --access-key <storage-account-access-key> \
      --mount-path /<mount-path>

    Repeat this for each of the 50+ shares, changing custom-id, share-name, and mount-path accordingly.

    1. Access Files in Your Function Code

    Once mounted, you can access the shares using standard file I/O:

    string[] files = Directory.GetFiles("/fx-files"); // fx-files is your mount path

     

Resources