My laptop is MacBook Pro (16-inch, 2021) Apple M1 Max.
I want to run Azure function with Python.
Currently, Azure function Core tools does not 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.
I already followed the instruction.
Install the Azure Functions Core Tools
So far, I did:
-
install Homebrew
-
Open terminal using Rosetta.
-
setting.json
"azureFunctions.deploySubpath": ".",
"azureFunctions.scmDoBuildDuringDeployment": true,
"azureFunctions.pythonVenv": ".venv",
"azureFunctions.projectLanguage": "Python",
"azureFunctions.projectRuntime": "~4",
"debug.internalConsoleOptions": "neverOpen",
"terminal.integrated.profiles.osx": {
"rosetta": {
"path": "arch",
"args": ["-x86_64", "zsh", "-l"],
"overrideName": true
}
}
}
- I have .zshrc file in the root folder which my project located.
# rosetta terminal setup
if [ $(arch) = "i386" ]; then
alias python="/usr/local/bin/python3"
alias brew86='/usr/local/bin/brew'
alias pyenv86="arch -x86_64 pyenv"
alias func="/usr/local/Cellar/azure-functions-core-tools@4/4.0.5095/func"
fi
so in VS code editor, I have rosetta terminal. run arch will show i386 which emulate ARM64.
- copy
azure-functions-core-tools@4/4.0.5095
folder fromopt/homebrew/Cellar/azure-functions-core-tools@4
past to/usr/local/Cellar/azure-functions-core-tools@4/4.0.5095/func"
because if I install azure-functions-core-tools@4 from terminal, it always goes to homebrew folder.
If run func host start
in Rosetta terminal, it showed error that
Failed to initialize worker provider for: /usr/local/Cellar/azure-functions-core-tools@4/4.0.5095/workers/python
Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python.
Failed to initialize worker provider for: /usr/local/Cellar/azure-functions-core-tools@4/4.0.5095/workers/python……(skip)
I already follow any solution from online, most are this way to run azure function on M1 Chip.
Is there any wrong I did or something I missing?
4/13 update
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.*, 4.0.0)"
}
}
2
Answers
All the tools you have installed are correct and once again check the Azure Functions core tools, Python version is installed properly.
Check the
host.json
file to check the Python executable path is given properly with the setting oflanguageWorkers:python:pythonPath
I know that Microsoft explicitly mentioned that Functions (Python) not supported on ARM64 devices but emulated x86 environment is the provided alternative.
Give the both architectures code in the zsh environment so that it detects automatically and runs in that environment as shown in this GitHub Article.
If still not yet resolved, you can raise the issue in the official forum of Azure Functions Host in GitHub by providing your environment and the issue details.
Try add this new setting on your .vscode/settings.json