Skip to content

Commit 62149bc

Browse files
authored
Merge pull request #106383 from ggailey777/storage
Python 3.8 and mounting storage shares
2 parents 09fe1b0 + 5757f79 commit 62149bc

7 files changed

+95
-10
lines changed

articles/azure-functions/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
displayName: best practice
139139
- name: Storage considerations
140140
href: storage-considerations.md
141-
displayName: encryption, keys
141+
displayName: encryption, keys, mount, files
142142
- name: Functions Proxies
143143
href: functions-proxies.md
144144
- name: Networking options

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
|---|---|

articles/azure-functions/functions-create-first-azure-function-azure-cli.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Create a function in Azure that responds to HTTP requests
33
description: Learn how to create a function from the command line, then publish the local project to serverless hosting in Azure Functions.
44
ms.date: 01/28/2020
55
ms.topic: quickstart
6-
zone_pivot_groups: programming-languages-set-functions
6+
77
---
88

99
# Quickstart: Create a function in Azure that responds to HTTP requests
@@ -18,15 +18,20 @@ Before you begin, you must have the following:
1818

1919
+ An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
2020

21+
::: zone pivot="programming-language-csharp,programming-language-javascript,programming-language-typescript,programming-language-powershell"
2122
+ The [Azure Functions Core Tools](./functions-run-local.md#v2) version 2.7.1846 or a later 2.x version.
23+
::: zone-end
24+
::: zone pivot="programming-language-python"
25+
+ Python 3.6 and 3.7 require [Azure Functions Core Tools](./functions-run-local.md#v2) version 2.7.1846 or a later 2.x version. Python 3.8 requires [version 3.x](./functions-run-local.md#v2) of the Core Tools.
26+
::: zone-end
2227

2328
+ The [Azure CLI](/cli/azure/install-azure-cli) version 2.0.76 or later.
2429
::: zone pivot="programming-language-javascript,programming-language-typescript"
2530
+ [Node.js](https://nodejs.org/), Active LTS and Maintenance LTS versions (8.11.1 and 10.14.1 recommended).
2631
::: zone-end
2732

2833
::: zone pivot="programming-language-python"
29-
+ [Python 3.7](https://www.python.org/downloads/release/python-375/) or [Python 3.6](https://www.python.org/downloads/release/python-368/), which are supported by Azure Functions. Python 3.8 and later versions aren't yet supported.
34+
+ [Python 3.8](https://www.python.org/downloads/release/python-382/), [Python 3.7](https://www.python.org/downloads/release/python-375/), [Python 3.6](https://www.python.org/downloads/release/python-368/), which are supported by Azure Functions.
3035
::: zone-end
3136
::: zone pivot="programming-language-powershell"
3237
+ [PowerShell Core](/powershell/scripting/install/installing-powershell-core-on-windows)
@@ -46,11 +51,11 @@ Before you begin, you must have the following:
4651
+ Run `node --version` to check your Node.js version reports 8.x or 10.x.
4752
::: zone-end
4853
::: zone pivot="programming-language-python"
49-
+ Run `python --version` (Linux/MacOS) or `py --version` (Windows) to check your Python version reports 3.7.x or 3.6.x.
54+
+ Run `python --version` (Linux/MacOS) or `py --version` (Windows) to check your Python version reports 3.8.x, 3.7.x or 3.6.x.
5055

5156
## <a name="create-venv"></a>Create and activate a virtual environment
5257

53-
In a suitable folder, run the following commands to create and activate a virtual environment named `.venv`. Be sure to use Python 3.7 or 3.6, which are supported by Azure Functions.
58+
In a suitable folder, run the following commands to create and activate a virtual environment named `.venv`. Be sure to use Python 3.8, 3.7 or 3.6, which are supported by Azure Functions.
5459

5560

5661
# [bash](#tab/bash)
@@ -263,10 +268,12 @@ Use the following Azure CLI commands to create these items. Each command provide
263268
264269
The storage account incurs only a few cents (USD) for this quickstart.
265270
266-
1. Create the Functions app using the [az functionapp create](/cli/azure/functionapp#az-functionapp-create) command. In the following example, replace `<STORAGE_NAME>` with the name of the account you used in the previous step, and replace `<APP_NAME>` with a globally unique name appropriate to you. The `<APP_NAME>` is also the default DNS domain for the function app.
271+
1. Create the function app using the [az functionapp create](/cli/azure/functionapp#az-functionapp-create) command. In the following example, replace `<STORAGE_NAME>` with the name of the account you used in the previous step, and replace `<APP_NAME>` with a globally unique name appropriate to you. The `<APP_NAME>` is also the default DNS domain for the function app.
267272
268273
::: zone pivot="programming-language-python"
269-
If you are using Python 3.6, also change `--runtime-version` to `3.6`.
274+
If you are using Python 3.8, change `--runtime-version` to `3.8` and `--functions_version` to `3`.
275+
276+
If you are using Python 3.6, change `--runtime-version` to `3.6`.
270277
271278
```azurecli
272279
az functionapp create --resource-group AzureFunctionsQuickstart-rg --os-type Linux --consumption-plan-location westeurope --runtime python --runtime-version 3.7 --functions_version 2 --name <APP_NAME> --storage-account <STORAGE_NAME>

articles/azure-functions/functions-reference-python.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,18 @@ For local development, application settings are [maintained in the local.setting
390390

391391
## Python version
392392

393-
Currently, Azure Functions supports both Python 3.6.x and 3.7.x (official CPython distributions). When running locally, the runtime uses the available Python version. To request a specific Python version when you create your function app in Azure, use the `--runtime-version` option of the [`az functionapp create`](/cli/azure/functionapp#az-functionapp-create) command. Version change is allowed only on Function App creation.
393+
Azure Functions supports the following Python versions:
394+
395+
| Functions version | Python<sup>*</sup> versions |
396+
| ----- | ----- |
397+
| 3.x | 3.8<br/>3.7<br/>3.6 |
398+
| 2.x | 3.7<br/>3.6 |
399+
400+
<sup>*</sup>Official CPython distributions
401+
402+
To request a specific Python version when you create your function app in Azure, use the `--runtime-version` option of the [`az functionapp create`](/cli/azure/functionapp#az-functionapp-create) command. The Functions runtime version is set by the `--functions-version` option. The Python version is set when the function app is created and can't be changed.
403+
404+
When running locally, the runtime uses the available Python version.
394405

395406
## Package management
396407

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 mount 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.7. Azure Functions also [supports Python versions 3.6 and 3.8](../functions-reference-python.md#python-version).
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.

includes/functions-supported-languages.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ ms.custom: include file
1414
|Language |1.x |2.x| 3.x |
1515
|-----------------------------------------|------------|---| --- |
1616
|[C#](../articles/azure-functions/functions-reference-csharp.md)|GA (.NET Framework 4.7)|GA (.NET Core 2.2)| GA (.NET Core 3.1) |
17-
|[JavaScript](../articles/azure-functions/functions-reference-node.md)|GA (Node 6)|GA (Node 8 & 10)| GA (Node 10 & 12) |
17+
|[JavaScript](../articles/azure-functions/functions-reference-node.md#node-version)|GA (Node 6)|GA (Node 8 & 10)| GA (Node 10 & 12) |
1818
|[F#](../articles/azure-functions/functions-reference-fsharp.md)|GA (.NET Framework 4.7)|GA (.NET Core 2.2)| GA (.NET Core 3.1) |
1919
|[Java](../articles/azure-functions/functions-reference-java.md)|N/A|GA (Java 8)| GA (Java 8)|
2020
|[PowerShell](../articles/azure-functions/functions-reference-powershell.md) |N/A|GA (PowerShell Core 6)| GA (PowerShell Core 6)|
21-
|[Python](../articles/azure-functions/functions-reference-python.md)|N/A|GA (Python 3.6 & 3.7)| GA (Python 3.6 & 3.7)|
21+
|[Python](../articles/azure-functions/functions-reference-python.md)#python-version|N/A|GA (Python 3.6 & 3.7)| GA (Python 3.6, 3.7, & 3.8)|
2222
|[TypeScript](../articles/azure-functions/functions-reference-node.md#typescript) |N/A|GA<sup>1</sup>| GA<sup>1</sup> |
2323

2424

0 commit comments

Comments
 (0)