Skip to content

Bring your own storage (Linux consumption)

Bala G edited this page Dec 4, 2019 · 3 revisions

Support for Bring Your Own Storage (BYOS) is now available in all regions.

BYOS enables mounting azure files share as a r/w share available to all instances of a function app. Currently only Azure files is supported, support for mounting blobs (readonly) will be added later.

Adding a share to a function app:

The easiest way is to use the following Az CLI command

az webapp config storage-account add --name < Function-App-Name > --resource-group < Resource-Group > --subscription < Subscription-Id > --custom-id < Unique-Custom-Id > --storage-type AzureFiles --account-name < Storage-Account-Name > --share-name < File-Share-Name > --access-key < Storage-Account-AccessKey > --mount-path </path/to/mount>

custom-id

Any unique string

storage-type

Only AzureFiles is supported currently

share-name

Pre existing share

mount-path

Path at which the share will be accessible inside the container. has to be of the format /dir-name. Cannot start with /home.

Additional commands to modify / delete the file share configuration - https://docs.microsoft.com/en-us/cli/azure/webapp/config/storage-account?view=azure-cli-latest#az-webapp-config-storage-account-update

Accessing the share:

The mounted share will be available at the path specified. Ex: /path/to/mount The target directory can be accessed by file system apis

Ex:

var directories = Directory.EnumerateDirectories("/path/to/mount");

var files = Directory.EnumerateFiles("/a/different/mounted/path");

Note:

A max of 5 file shares can be mounted. Mounting a file share can add upto 200 - 300 ms to cold start (more if the storage account is in a different region).