:::: MENU ::::
Monthly Archives: February 2023

Azure Functions on Mac M1 with PyEnv

Saved me several times. Great and easy to follow approach by anthonysomerset.

When using PyEnv just change the location from which you copy the file (copy the lib step).

# Install Python
brew install python@3.9

# install latest azure-function-core-tools from brew
brew install azure-functions-core-tools@4 

# Install grpcio inside python3.9
pip3.9 install grpcio

# copy the lib
cp /opt/homebrew/lib/python3.9/site-packages/grpc/_cython/cygrpc.cpython-39-darwin.so /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4915/workers/python/3.9/OSX/X64/grpc/_cython/cygrpc.cpython-39-darwin.so

# symlink X64 to Arm64
cd /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4915/workers/python/3.9/OSX/
ln -s X64 Arm64

#edit the worker config to reference arm64
cd /opt/homebrew/Cellar/azure-functions-core-tools@4/4.0.4915/workers/python
#use your text editor of choice e.g. nano
nano worker.config.json
# update supportedArchitectures like so
"supportedArchitectures":["X64", "X86","ARM64"],
# save and exit

# in your function directory setup a python 3.9 venv
cd <path to azure functions code>
python3.9 -m venv .venv
source .venv/bin/activate

# start func
func start

Source: GitHub