Skip to content

Commit 244b89a

Browse files
author
Glenn Gailey
committed
Draft of BYOS
1 parent 7e1b12e commit 244b89a

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

articles/azure-functions/functions-cli-samples.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The following table includes links to bash scripts for Azure Functions that use
2626
|---|---|
2727
| [Create a function app and connect to a storage account](scripts/functions-cli-create-function-app-connect-to-storage-account.md) | Create a function app and connect it to a storage account. |
2828
| [Create a function app and connect to an Azure Cosmos DB](scripts/functions-cli-create-function-app-connect-to-cosmos-db.md) | Create a function app and connect it to an Azure Cosmos DB. |
29+
| [Create a Python function app and mount a Azure Files share](scripts/functions-cli-mount-files-storage-linux.md) | By mounting a share to your Linux function app, you can leverage existing machine learning models or other data in your functions. |
2930

3031
| Continuous deployment | Description|
3132
|---|---|
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: Mount a file share to a Python function app - Azure CLI
3+
description: Create a serverless Python function app and mpunt an existing file share using the Azure CLI
4+
ms.topic: sample
5+
ms.date: 03/01/2020
6+
---
7+
8+
# Mount a file share to a Python function app using Azure CLI
9+
10+
This Azure Functions sample script creates a function app and creates a share in Azure Files. It them mounts the share so that the data can be accessed by your functions.
11+
12+
>[!NOTE]
13+
>The function app created runs on Python version 3.6. Python version 3.7 is also supported by Azure Functions.
14+
15+
[!INCLUDE [quickstarts-free-trial-note](../../../includes/quickstarts-free-trial-note.md)]
16+
17+
[!INCLUDE [cloud-shell-try-it.md](../../../includes/cloud-shell-try-it.md)]
18+
19+
If you choose to install and use the CLI locally, this article requires that you are running the Azure CLI version 2.0 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install the Azure CLI]( /cli/azure/install-azure-cli). Examples are written for Bash shell and must be modified to run in a Windows command prompt.
20+
21+
## Sample script
22+
23+
This script creates an Azure Function app using the [Consumption plan](../functions-scale.md#consumption-plan).
24+
25+
[!code-azurecli-interactive[main](../../../cli_scripts/azure-functions/functions-cli-mount-files-storage-linux/functions-cli-mount-files-storage-linux.sh "Create an Azure Function on a Consumption plan")]
26+
27+
[!INCLUDE [cli-script-clean-up](../../../includes/cli-script-clean-up.md)]
28+
29+
## Script explanation
30+
31+
Each command in the table links to command specific documentation. This script uses the following commands:
32+
33+
| Command | Notes |
34+
|---|---|
35+
| [az group create](/cli/azure/group#az-group-create) | Creates a resource group in which all resources are stored. |
36+
| [az storage account create](/cli/azure/storage/account#az-storage-account-create) | Creates an Azure Storage account. |
37+
| [az functionapp create](/cli/azure/functionapp#az-functionapp-create) | Creates a function app. |
38+
| [az storage share create](/cli/azure/storage/share#az-storage-share-create) | Creates an Azure Files share in storage account. |
39+
| [az storage directory create](/cli/azure/storage/directory#az-storage-directory-create) | Creates a directory in the share. |
40+
| [az webapp config storage-account add](/cli/azure/webapp/config/storage-account#az-webapp-config-storage-account-add) | Mounts the share to the function app. |
41+
| [az webapp config storage-account list](/cli/azure/webapp/config/storage-account#az-webapp-config-storage-account-list) | Shows file shares mounted to the function app. |
42+
43+
## Next steps
44+
45+
For more information on the Azure CLI, see [Azure CLI documentation](/cli/azure).
46+
47+
Additional Azure Functions CLI script samples can be found in the [Azure Functions documentation](../functions-cli-samples.md).

articles/azure-functions/storage-considerations.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@ Azure Storage encrypts all data in a storage account at rest. For more informati
5353

5454
By default, data is encrypted with Microsoft-managed keys. For additional control over encryption keys, you can supply customer-managed keys to use for encryption of blob and file data. These keys must be present in Azure Key Vault for Functions to be able to access the storage account. To learn more, see [Configure customer-managed keys with Azure Key Vault by using the Azure portal](../storage/common/storage-encryption-keys-portal.md).
5555

56+
## Mount file shares (Linux)
57+
58+
You can mount existing Azure Files shares to your Linux function apps. By mounting a share to your Linux function app, you can leverage existing machine learning models or other data in your functions. You can use the [`az webapp config storage-account add`](/cli/azure/webapp/config/storage-account#az-webapp-config-storage-account-add) command to mount an existing share to your Linux function app.
59+
60+
In this command, `share-name` is the name of the existing Azure Files share, and `custom-id` can be any string that uniquely defines the share when mounted to the function app. Also, `mount-path` is the path from which the share is accessed in your function app. `mount-path` must be in the format `/dir-name`, and it can't start with `/home`.
61+
62+
For a complete example, see the scripts in [Create a Python function app and mount a Azure Files share](scripts/functions-cli-mount-files-storage-linux.md).
63+
64+
Currently, only a `storage-type` of `AzureFiles` is supported. You can only mount five shares to a given function app. Mounting a file share may increase the cold start time by at least 200-300ms, or even more when the storage account is in a different region.
65+
66+
The mounted share is available to your function code at the `mount-path` specified. For example, when `mount-path` is `/path/to/mount`, you can access the target directory by file system APIs, as in the following Python example:
67+
68+
```python
69+
import os
70+
...
71+
72+
files_in_share = os.listdir("/path/to/mount")
73+
```
74+
5675
## Next steps
5776

5877
Learn more about Azure Functions hosting options.

0 commit comments

Comments
 (0)