Skip to content

Commit 6b4dc0e

Browse files
Merge pull request #220466 from ggailey777/shreya
[Functions] MacOS AMD64 emulation content
2 parents 10f765e + 1f394e9 commit 6b4dc0e

11 files changed

+145
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ Before you begin, you must have the following requirements in place:
4545
+ The [Azurite storage emulator](../storage/common/storage-use-azurite.md?tabs=npm#install-azurite). While you can also use an actual Azure Storage account, the article assumes you're using this emulator.
4646
::: zone-end
4747

48+
[!INCLUDE [functions-x86-emulation-on-arm64-note](../../includes/functions-x86-emulation-on-arm64-note.md)]
49+
4850
### Prerequisite check
4951

5052
Verify your prerequisites, which depend on whether you're using Azure CLI or Azure PowerShell for creating Azure resources.

articles/azure-functions/create-first-function-vs-code-python.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Before you begin, make sure that you have the following requirements in place:
4848
+ The [Azurite V3 extension](https://marketplace.visualstudio.com/items?itemName=Azurite.azurite) local storage emulator. While you can also use an actual Azure storage account, this article assumes you're using the Azurite emulator.
4949
::: zone-end
5050

51+
[!INCLUDE [functions-x86-emulation-on-arm64-note](../../includes/functions-x86-emulation-on-arm64-note.md)]
52+
5153
## <a name="create-an-azure-functions-project"></a>Create your local project
5254

5355
In this section, you use Visual Studio Code to create a local Azure Functions project in Python. Later in this article, you'll publish your function code to Azure.

articles/azure-functions/functions-develop-vs-code.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ These prerequisites are only required to [run and debug your functions locally](
9191

9292
* [Python extension](https://marketplace.visualstudio.com/items?itemName=ms-python.python) for Visual Studio Code.
9393

94+
[!INCLUDE [functions-x86-emulation-on-arm64-note](../../includes/functions-x86-emulation-on-arm64-note.md)]
95+
9496
---
9597

9698
## Create an Azure Functions project
@@ -491,6 +493,27 @@ We recommend that you monitor the execution of your functions by integrating you
491493

492494
To learn more about monitoring using Application Insights, see [Monitor Azure Functions](functions-monitoring.md).
493495

496+
[!INCLUDE [functions-x86-emulation-on-arm64](../../includes/functions-x86-emulation-on-arm64.md)]
497+
498+
### Enable emulation in Visual Studio Code
499+
500+
Now that you've configured the Terminal with Rosetta to run x86 emulation for Python development, you can use the following steps to integrate this terminal emulation with Visual Studio Code:
501+
502+
1. Open the Command Palette by pressing Cmd+Shift+P, select **Preferences: Open Settings (JSON)**, and add the following JSON to your configuration:
503+
504+
```json
505+
"terminal.integrated.profiles.osx": {
506+
"rosetta": {
507+
"path": "arch",
508+
"args": ["-x86_64", "zsh", "-l"],
509+
"overrideName": true
510+
}
511+
}
512+
```
513+
1. Open a new Terminal and choose **rosetta**.
514+
515+
![Screenshot of starting a new Rosetta terminal in Visual Studio Code.](./media/functions-develop-vs-code/vs-code-rosetta.png)
516+
494517
## C\# script projects
495518

496519
By default, all C# projects are created as [C# compiled class library projects](functions-dotnet-class-library.md). If you prefer to work with C# script projects instead, you must select C# script as the default language in the Azure Functions extension settings:

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

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,27 @@ As a Python developer, you might also be interested in one of the following arti
3434

3535
::: zone-end
3636

37-
> [!NOTE]
38-
> Although you can develop your Python-based Azure functions locally on Windows, Python is supported only on a Linux-based hosting plan when it's running in Azure. For more information, see the [list of supported operating system/runtime combinations](functions-scale.md#operating-systemruntime).
37+
## Development options
38+
39+
Both Python Functions programming models support local development in one of the following environments:
40+
41+
Python v2 programming model:
42+
43+
+ [Visual Studio Code](./create-first-function-vs-code-python.md?pivots=python-mode-decorators)
44+
+ [Terminal or command prompt](./create-first-function-cli-python.md?pivots=python-mode-decorators)
45+
46+
Python v1 programming model:
47+
48+
+ [Visual Studio Code](./create-first-function-vs-code-python.md?pivots=python-mode-configuration)
49+
+ [Terminal or command prompt](./create-first-function-cli-python.md?pivots=python-mode-configuration)
50+
51+
You can also create Python v1 functions in the Azure portal.
52+
53+
The following considerations apply for local Python development:
54+
55+
+ Although you can develop your Python-based Azure functions locally on Windows, Python is supported only on a Linux-based hosting plan when it's running in Azure. For more information, see the [list of supported operating system/runtime combinations](functions-scale.md#operating-systemruntime).
56+
57+
+ Functions doesn't currently support local Python function development on ARM64 devices, including on a Mac with an M1 chip. To learn more, see [x86 emulation on ARM64](functions-run-local.md#x86-emulation-on-arm64).
3958

4059
## Programming model
4160

articles/azure-functions/functions-run-local.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ If you need to install version 1.x of the Core Tools, see the [GitHub repository
100100
101101
# [macOS](#tab/macos/v4)
102102
103+
[!INCLUDE [functions-x86-emulation-on-arm64-note](../../includes/functions-x86-emulation-on-arm64-note.md)]
104+
103105
The following steps use Homebrew to install the Core Tools on macOS.
104106
105107
1. Install [Homebrew](https://brew.sh/), if it's not already installed.
@@ -115,6 +117,8 @@ The following steps use Homebrew to install the Core Tools on macOS.
115117
116118
# [macOS](#tab/macos/v3)
117119
120+
[!INCLUDE [functions-x86-emulation-on-arm64-note](../../includes/functions-x86-emulation-on-arm64-note.md)]
121+
118122
The following steps use Homebrew to install the Core Tools on macOS.
119123
120124
1. Install [Homebrew](https://brew.sh/), if it's not already installed.
@@ -130,6 +134,8 @@ The following steps use Homebrew to install the Core Tools on macOS.
130134
131135
# [macOS](#tab/macos/v2)
132136
137+
[!INCLUDE [functions-x86-emulation-on-arm64-note](../../includes/functions-x86-emulation-on-arm64-note.md)]
138+
133139
The following steps use Homebrew to install the Core Tools on macOS.
134140
135141
1. Install [Homebrew](https://brew.sh/), if it's not already installed.
@@ -602,8 +608,11 @@ You can view a stream of log files being generated by your functions in a comman
602608

603609
[!INCLUDE [functions-streaming-logs-core-tools](../../includes/functions-streaming-logs-core-tools.md)]
604610

605-
This type of streaming logs requires that Application Insights integration be enabled for your function app.
611+
This type of streaming logs requires that Application Insights integration be enabled for your function app.
612+
613+
[!INCLUDE [functions-x86-emulation-on-arm64](../../includes/functions-x86-emulation-on-arm64.md)]
606614

615+
If you are using Visual Studio Code, you can integrate Rosetta with the built-in Terminal. For more information, see [Enable emulation in Visual Studio Code](./functions-develop-vs-code.md#enable-emulation-in-visual-studio-code).
607616

608617
## Next steps
609618

20.9 KB
Loading
51.7 KB
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
author: ggailey777
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 12/05/2022
6+
ms.author: glenga
7+
---
8+
9+
> [!IMPORTANT]
10+
> Functions doesn't currently support Python function development on ARM64 devices. To develop Python functions on a Mac with an M1 chip, you must run in an emulated x86 environment. To learn more, see [x86 emulation on ARM64](../articles/azure-functions/functions-run-local.md#x86-emulation-on-arm64).
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
author: ggailey777
3+
ms.service: azure-functions
4+
ms.topic: include
5+
ms.date: 12/05/2022
6+
ms.author: glenga
7+
---
8+
9+
## x86 emulation on ARM64
10+
11+
Functions doesn't currently support local Python function development on ARM64 devices. Use the following steps to develop Python functions on a Mac with an M1 chip by running in an emulated x86 environment.
12+
13+
### Enable Rosetta in Terminal
14+
15+
1. In your Mac, open Finder, choose **Applications**, and locate **Terminal**.
16+
17+
1. Control-click **Terminal** and select **Get Info**. You can also create a separate parallel environment by duplicating the Terminal and renaming it.
18+
19+
![Screenshot of selecting Get Info by control-clicking Terminal](./media/functions-x86-emulation-on-arm64/arm64-python-1.png)
20+
21+
1. Select **Open using Rosetta**.
22+
23+
![Screenshot of the Terminal configured to open using Rosetta](./media/functions-x86-emulation-on-arm64/arm64-python-2.png)
24+
25+
1. Open Terminal, which now has Rosetta enabled, and make sure your shell is zsh.
26+
27+
1. Run the following command to validate the x86 emulation.
28+
29+
```cmd
30+
$ arch
31+
```
32+
33+
A response of `i386` indicates your terminal is running an x86 emulated environment.
34+
35+
### Install required packages
36+
37+
Reinstall all dependencies required by Functions in this environment, which includes the following packages:
38+
39+
* [homebrew](https://brew.sh/), installed to the path `/usr/local/bin/brew`.
40+
* Python
41+
* [Azure Functions Core Tools](/functions-run-local.md#install-the-azure-functions-core-tools)
42+
43+
Also, reinstall any other packages required by your Python project.
44+
45+
### Set aliases (optional)
46+
47+
You can optionally set aliases to make it easy to reference the right versions in Rosetta.
48+
49+
The following is an example of how to create a .zshrc file to configure your zsh terminal:
50+
51+
```c
52+
# file: .zshrc
53+
# rosetta terminal setup
54+
if [ $(arch) = "i386" ]; then
55+
alias python="/usr/local/bin/python3"
56+
alias brew86='/usr/local/bin/brew'
57+
alias pyenv86="arch -x86_64 pyenv"
58+
alias func="/usr/local/Cellar/azure-functions-core-tools@4/4.0.4785/func"
59+
fi
60+
```
61+
62+
Run the following command to apply the aliases:
63+
64+
```cmd
65+
$ source .zshrc
66+
```
67+
68+
Validate you're referencing the correct versions by using the `which` command, as shown in the following examples:
69+
70+
| Command | Example response |
71+
| --- | --- |
72+
| `$ which python` | `python: aliased to /usr/local/bin/python3` |
73+
| `$ which func` | `func: aliased to /usr/local/Cellar/azure-functions-core-tools@4/4.0.4785/func` |
74+
75+
These example responses are based on the previous example .zshrc file.
76+
77+
Now, you're set up to use Azure Functions in the x86 environment from the Terminal.
23.2 KB
Loading

0 commit comments

Comments
 (0)