Azure Functions Core Tools is great tool that allows developing and testing functions on your local machine. Unfortunately, Azure Function Core Tools does not support local python function development on mac OS with arm64 processors i.e. M1 and M2 macs.
Until today there is an open issue on Github you can follow.
When trying to run the python function func start you will receive the following error
Microsoft.Azure.WebJobs.Script: Architecture Arm64 is not supported for language python
The workaround consists of creating an emulated environment of x64 and install all required dependencies.
Prepare the 86x emulation environment
- In your Mac, open Finder, choose Applications, and locate Terminal.
- Create a separate parallel environment by duplicating the Terminal and renaming it to
- Click right on the new terminal application iTermx86 then click info.
- Make sure you enable Open using Rosseta in the the new terminal application
- In order to check the 86x emulation on the new terminal run
The expected response is
Install Required Tools
Once you have the 86x emulation up and running it is time to install tools and dependencies.
- Azure Functions Core Tools
Note: Make sure to run all the commands in the new terminal
- Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Make sure the homebrew is installed to this path
- Install Python using homebrew
/usr/local/bin/brew install firstname.lastname@example.org
- Verify that python has been installed to
- Install Azure Functions Core Tools
/usr/local/bin/brew tap azure/functions /usr/local/bin/brew install azure-functions-core-tools@4
- Verify that Azure Core has been installed in
In order to make the usage of brew, python and azure functions easy it is better to add the following aliases to your ~/.zshrc file
- Update ~/.zshrc
if [ $(arch) = "i386" ]; then alias python3="/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.4915/func" fi
- Restart your terminal or source your ~/.zshrc file
- Validate the the correct packages and versions by running.
which python3 which brew86 which func
Running Azure Function Locally
Now all the required packages are installed it is time to run new azure function
- Create new virtual environment and activate it.
cd <azure_function_project> python3 -m venv venv source venv/bin/activate
- Install required dependencies if exists
pip install -t requirements
- Run the Azure Function locally