azure-functions-core-tools: "Function not implemented" error on Mac M1, works on Ubuntu

Hey team,

I’m currently stuck in the “Function not implemented” error which blocks me from using my Mac. How to reproduce:

  1. Follow https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local to create a nodejs function, add "start": "func start" into package.json
  2. Create a Dockerfile to use ubuntu:bionic image and install depedencies
FROM --platform=linux/amd64 ubuntu:bionic

RUN apt update && \
  apt install -y \
  apt-transport-https \
  curl \
  lsb-release gnupg \
  virtualenv && \
  curl -sL https://packages.microsoft.com/keys/microsoft.asc | \
  gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.asc.gpg && \
  curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | \
  apt-key add && \
  echo \
  "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $(lsb_release -cs) main" \
  > /etc/apt/sources.list.d/azure-cli.list && \
  echo \
  "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-$(lsb_release -cs)-prod $(lsb_release -cs) main" \
  > /etc/apt/sources.list.d/dotnetdev.list && \
  echo "deb https://deb.nodesource.com/node_10.x disco main" \
  > /etc/apt/sources.list.d/nodesource.list && \
  apt update && \
  apt install -y \
  azure-cli \
  azure-functions-core-tools \
  libicu-dev \
  build-essential \
  nodejs \
  unzip \
  zip && \
  useradd -m azure && \
  chown -R azure:azure /home/azure/.bashrc && \
  mkdir -p /root/.azure-functions-core-tools/Functions/ExtensionBundles && \
  cd /root/.azure-functions-core-tools/Functions/ExtensionBundles && \
  curl -O https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/2.4.0/Microsoft.Azure.Functions.ExtensionBundle.2.4.0.zip && \
  mkdir -p Microsoft.Azure.Functions.ExtensionBundle/2.4.0 && \
  unzip Microsoft.Azure.Functions.ExtensionBundle.2.4.0.zip -d Microsoft.Azure.Functions.ExtensionBundle/2.4.0 && \
  cd -

USER azure
  1. Create a docker-compose.yaml file
version: "3.7"

services:
  demo:
    container_name: demo
    build:
      context: .
      dockerfile: ./Dockerfile
    user: root
    working_dir: /work
    ports:
      - "7071:7071"
    volumes:
      - ./MyFunctionProj:/work
    command: sh -c "ls -lrt && npm start -- -p 7071 --cors-credentials --cors 'http://localhost:7070'"

networks:
  default:
    driver: bridge
    driver_opts:
      com.docker.network.driver.mtu: 1400
  1. Start the docker in Ubuntu environment and Mac M1 environment

Thank you. Folder Mac-M1 Ubuntu

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 14
  • Comments: 51 (6 by maintainers)

Most upvoted comments

I was facing the same issue on my Mac M1. I have managed to resolve it by doing the following

  • update docker to 4.16.2
  • enable “Use rosetta for x86/amd64 … " option in settings > Features in development”
  • set platform to “linux/amd64” when running docker build

You can follow detailed steps and explanation here http://issamben.com/running-azure-function-as-docker-container-on-an-m1-m2/

@anthonychu @stefanushinardi Can you please provide an update for ETA on developing Azure Functions on an M1 chip in docker? Is this a Docker issue or an Azure Functions issue?

Here’s my workaround to create an env that Azure will tolerate on Apple Silicon…

Workaround on Apple Silicon

1. Installing Rosetta

  1. Run the following command in terminal: softwareupdate --install-rosetta --agree-to-license
    • This will install Apple’s Rosetta which emulates x64_86 architecture.
  2. Navigate to ~/Applications/ and duplicate ‘Terminal’
    • You may wish to rename the duplicate “Rosetta Terminal”
  3. Secondary-click your new terminal, navigate to ‘Get Info’, and check the ‘Open using Rosetta’ box.

You have now created a second terminal application that will always run as x64_86. Test this by entering arch, it should show as i386 as opposed to arm64. You can always enter python -c "import platform;print(platform.machine())" to test that the Python interpreter is running on Rosetta.

The two terminals share the same preferences (i.e. theme), so using a new icon for the Rosetta terminal is advised. The process for replacing an application icon is well documented online. A high-fidelity image of the Apple Rosetta logo can be found here

2. Installing Dependencies

  1. Install the intel arch for brew: arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
    • Good practice to run echo 'eval "$(/usr/local/bin/brew shellenv)"' >> /Users/USERNAME/.zprofile and eval "$(/usr/local/bin/brew shellenv)" after brew install
  2. Create a new Conda env (named rosetta): CONDA_SUBDIR=osx-64 conda create -n rosetta python=3.9

⚠️ Python 3.9.X is the latest version supported by Azure CLI & Funcs

  1. Activate new Conda env: conda activate rosetta
  2. Install Azure Functions Core Tools by running arch -x86_64 brew tap azure/functions then arch -x86_64 brew install azure-functions-core-tools@4
  3. Install Azure CLI: arch -x86_64 brew update && arch -x86_64 brew install azure-cli
  4. Run az login to authenticate in browser.
    • You should see something like the following…
     [
       {
         "cloudName": "AzureCloud",
         "homeTenantId": "a000000-b000-c000-d000-e00000000000",
         "id": "a000000-b000-c000-d000-e00000000000",
         "isDefault": true,
         "managedByTenants": [],
         "name": "Pay-As-You-Go",
         "state": "Enabled",
         "tenantId": "a000000-b000-c000-d000-e00000000000",
         "user": {
           "name": "first.last@example.com",
           "type": "user"
         }
       }
     ]
    
  5. Navigate to the project directory & run pip install -r requirements.txt

3. Testing that all is A-OK

  1. Start the app: Azure already knows that the directory contains a function app. <mark>You do not need to initiate a new function app</mark>, simply run func start host
    • Your endpoint should be localhost:7071...
    • There is no authentication 👋 Goodbye Ocp-Apim-Subscription-Key
    • Should the above perform as expected, you’re off… Happy Coding 🤖🚀

Here’s my workaround to create an env that Azure will tolerate on Apple Silicon…

Workaround on Apple Silicon

1. Installing Rosetta

  1. Run the following command in terminal: softwareupdate --install-rosetta --agree-to-license

    • This will install Apple’s Rosetta which emulates x64_86 architecture.
  2. Navigate to ~/Applications/ and duplicate ‘Terminal’

    • You may wish to rename the duplicate “Rosetta Terminal”
  3. Secondary-click your new terminal, navigate to ‘Get Info’, and check the ‘Open using Rosetta’ box.

You have now created a second terminal application that will always run as x64_86. Test this by entering arch, it should show as i386 as opposed to arm64. You can always enter python -c "import platform;print(platform.machine())" to test that the Python interpreter is running on Rosetta.

The two terminals share the same preferences (i.e. theme), so using a new icon for the Rosetta terminal is advised. The process for replacing an application icon is well documented online. A high-fidelity image of the Apple Rosetta logo can be found here

2. Installing Dependencies

  1. Install the intel arch for brew: arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

    • Good practice to run echo 'eval "$(/usr/local/bin/brew shellenv)"' >> /Users/USERNAME/.zprofile and eval "$(/usr/local/bin/brew shellenv)" after brew install
  2. Create a new Conda env (named rosetta): CONDA_SUBDIR=osx-64 conda create -n rosetta python=3.9

⚠️ Python 3.9.X is the latest version supported by Azure CLI & Funcs

  1. Activate new Conda env: conda activate rosetta

  2. Install Azure Functions Core Tools by running arch -x86_64 brew tap azure/functions then arch -x86_64 brew install azure-functions-core-tools@4

  3. Install Azure CLI: arch -x86_64 brew update && arch -x86_64 brew install azure-cli

  4. Run az login to authenticate in browser.

    • You should see something like the following…
     [
       {
         "cloudName": "AzureCloud",
         "homeTenantId": "a000000-b000-c000-d000-e00000000000",
         "id": "a000000-b000-c000-d000-e00000000000",
         "isDefault": true,
         "managedByTenants": [],
         "name": "Pay-As-You-Go",
         "state": "Enabled",
         "tenantId": "a000000-b000-c000-d000-e00000000000",
         "user": {
           "name": "first.last@example.com",
           "type": "user"
         }
       }
     ]
    
  5. Navigate to the project directory & run pip install -r requirements.txt

3. Testing that all is A-OK

  1. Start the app: Azure already knows that the directory contains a function app. You do not need to initiate a new function app, simply run func start host

    • Your endpoint should be localhost:7071...
    • There is no authentication 👋 Goodbye Ocp-Apim-Subscription-Key
    • Should the above perform as expected, you’re off… Happy Coding 🤖🚀

Locally the functions work fine. The issue is when running in a container.

Any updates on this issue ? I am experiencing the same difficulties on an M1 chip.

Thanks @wangcarlton. @diberry just reported the same issue. Looks like maybe one of the OS APIs used by the filewatcher isn’t implemented when running in a linux/amd64 container when running on an M1 docker host.

Really, 1 Year and 8 Months since the issue is opened and still there? Is this the way for MS to say they don’t care for Devs on Macs?

Similar issues when launching the devcontainer Azure Functions template: Azure Functions & PowerShell on M1 MacBook Pro.

func host start

Azure Functions Core Tools
Core Tools Version:       3.0.4806 Commit hash: N/A  (64-bit)
Function Runtime Version: 3.13.1.0

Skipping 'FUNCTIONS_WORKER_RUNTIME' from local settings as it's already defined in current environment variables.
Function not implemented
# Find the Dockerfile for mcr.microsoft.com/azure-functions/powershell:3.0-powershell${VARIANT}-core-tools at this URL
# https://github.com/Azure/azure-functions-docker/blob/dev/host/3.0/buster/amd64/powershell

# Update the VARIANT arg in devcontainer.json to pick a supported PowerShell version: 7, 6
ARG VARIANT=7
FROM mcr.microsoft.com/azure-functions/powershell:3.0-powershell${VARIANT}-core-tools
ENV ASPNETCORE_hostBuilder__reloadConfigOnChange=false

Devcontainer.json

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/azure-functions-pwsh
{
	"name": "Azure Functions & PowerShell",
	"build": {
		"dockerfile": "Dockerfile",
		"args": {
			// Update the VARIANT arg to pick a supported PowerShell version: 7, 6
			"VARIANT": "7"
		}
	},
	"forwardPorts": [ 7071 ],

	// Configure tool-specific properties.
	"customizations": {
		// Configure properties specific to VS Code.
		"vscode": {
			// Set *default* container specific settings.json values on container create.
			"settings": {
				"terminal.integrated.defaultProfile.linux": "pwsh"
			},

			// Add the IDs of extensions you want installed when the container is created.
			"extensions": [
				"ms-azuretools.vscode-azurefunctions",
				"ms-vscode.powershell",
				"Azurite.azurite"
			]
		}
	},

	// Use 'postCreateCommand' to run commands after the container is created.
	// "postCreateCommand": "dotnet restore",

	// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
	"remoteUser": "vscode"
}

Also tried with mcr.microsoft.com/azure-functions/powershell:4-powershell7.2 which gives a similar error:

[2022-10-04T11:47:48.487Z] A host error has occurred during startup operation ‘fcc0f38c-4fdf-459d-a045-171eba07997c’. [2022-10-04T11:47:48.494Z] System.IO.FileSystem.Watcher: Function not implemented. Value cannot be null. (Parameter ‘provider’) [2022-10-04T11:47:48.755Z] Failed to start a new language worker for runtime: powershell. [2022-10-04T11:47:48.755Z] System.Private.CoreLib: A task was canceled.

Facing the same issue, any updates on this?

For whomever may get here later, besides upgrading docker and enable rosetta in docker, you may also consider upgrading Mac OS version, which has been helpful for me, as without it docker may not even show the enable rosetta button.

I was facing the same issue on my Mac M1. I have managed to resolve it by doing the following

  • update docker to 4.16.2
  • enable “Use rosetta for x86/amd64 … " option in settings > Features in development”
  • set platform to “linux/amd64” when running docker build

You can follow detailed steps and explanation here http://issamben.com/running-azure-function-as-docker-container-on-an-m1-m2/

Good heavens! Lost 2 hours trying to resolve this until I stumbled across this thread! It worked - thank you so much!

Hey everybody,

Anybody who has trouble starting the Azure Function via console should check if your Azure Functions Core Tool is compatible with your .NET Core version. For example Azure Functions Core Tool 3.1 did not work for me with .NET Core 6.x .

Azure Functions runtime versions overview: https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=in-process%2Cv4&pivots=programming-language-csharp


But I am facing a simialar same problem on a Docker image (built from MacBook Air with M1-Chip). I set up an Azure Function with Azure Functions Core Tools (4.0.3971).

func init --docker (dotnet)

func new (BlobTrigger)

The function is running inside Visual Studio and from the console (.Net Core 6.0.3 installed). But when I build my docker image with the following command:

docker build --platform linux/arm64/v8 -t someimagename

and if I try to run it:

docker run -it someimagename

I get the following error:

fail: Host.Startup[515] A host error has occurred during startup operation ‘bb827579-ddf0-4bc0-9ff8-abea885e77bb’. System.IO.IOException: Function not implemented at System.IO.FileSystemWatcher.StartRaisingEvents() at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed() at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value) at Microsoft.Azure.WebJobs.Script.IO.AutoRecoveringFileSystemWatcher.InitializeWatcher() in /src/azure-functions-host/src/WebJobs.Script/IO/AutoRecoveringFileSystemWatcher.cs:line 64 at Microsoft.Azure.WebJobs.Script.IO.AutoRecoveringFileSystemWatcher…ctor(String path, String filter, Boolean includeSubdirectories, WatcherChangeTypes changeTypes, ILoggerFactory loggerFactory) in /src/azure-functions-host/src/WebJobs.Script/IO/AutoRecoveringFileSystemWatcher.cs:line 43 at Microsoft.Azure.WebJobs.Script.Eventing.File.FileWatcherEventSource…ctor(IScriptEventManager eventManager, String source, String path, String filter, Boolean includeSubdirectories, WatcherChangeTypes changeTypes, ILoggerFactory loggerFactory) in /src/azure-functions-host/src/WebJobs.Script/Eventing/File/FileWatcherEventSource.cs:line 28 at Microsoft.Azure.WebJobs.Script.WebHost.FileMonitoringService.InitializeFileWatchers() in /src/azure-functions-host/src/WebJobs.Script.WebHost/FileMonitoringService.cs:line 157 at Microsoft.Azure.WebJobs.Script.WebHost.FileMonitoringService.StartAsync(CancellationToken cancellationToken) in /src/azure-functions-host/src/WebJobs.Script.WebHost/FileMonitoringService.cs:line 93 at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken) at Microsoft.Azure.WebJobs.Script.WebHost.WebJobsScriptHostService.UnsynchronizedStartHostAsync(ScriptHostStartupOperation activeOperation, Int32 attemptCount, JobHostStartupMode startupMode) in /src/azure-functions-host/src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs:line 309

Same error if I do not specifiy the platform building the docker image.

Here is my Dockerfile:


FROM mcr.microsoft.com/dotnet/sdk:6.0 AS installer-env

COPY --from=mcr.microsoft.com/dotnet/core/sdk:3.1 /usr/share/dotnet /usr/share/dotnet

COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
    mkdir -p /home/site/wwwroot && \
    dotnet publish *.csproj --output /home/site/wwwroot

FROM mcr.microsoft.com/azure-functions/dotnet:4
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

ENV AzureWebJobsStorage="someconnectionkey"

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

I switched over using these images and that seems to work fine. Hopefully official support for arm64 drops soon. https://github.com/Azure/azure-functions-docker/issues/487#issuecomment-1236274099

I encountered the same issue running a simple ASP.NET app on M1 macOS.

I was able to resolve it by adding an environment variable to disable automatic config reload. Not sure if it would apply to Azure Functions as well, but it looks like the same call stack.

ENV ASPNETCORE_hostBuilder__reloadConfigOnChange=false

Same issue here on Apple M1 with the following dockerfile

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS installer-env

# Build requires 3.1 SDK
COPY --from=mcr.microsoft.com/dotnet/core/sdk:3.1 /usr/share/dotnet /usr/share/dotnet

COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && \
    mkdir -p /home/site/wwwroot && \
    dotnet publish *.csproj --output /home/site/wwwroot

FROM mcr.microsoft.com/azure-functions/dotnet:4
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]