Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.28k stars 423 forks source link

"Function not implemented" error on Mac M1, works on Ubuntu #2901

Open wangcarlton opened 2 years ago

wangcarlton commented 2 years ago

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:

networks: default: driver: bridge driver_opts: com.docker.network.driver.mtu: 1400



4. Start the docker in Ubuntu environment and Mac M1 environment

Thank you.
![Folder](https://user-images.githubusercontent.com/35724343/149281742-f6b27f38-7349-4f0d-98ee-1670d75de25f.png)
<img width="1154" alt="Mac-M1" src="https://user-images.githubusercontent.com/35724343/149281749-8a048240-dce3-4aac-b18a-35031327b550.png">
![Ubuntu](https://user-images.githubusercontent.com/35724343/149281758-efca18f1-7c36-4842-b049-04a2df53ac44.png)
michaelpeng36 commented 2 years ago

@wangcarlton could you try using a more up-to-date version of Core Tools? You can do this by using azure-functions-core-tools-3 or azure-functions-core-tools-4 rather than azure-functions-core-tools. Could you also specify the reason this is being done in a docker environment? Is this to get around a specific limitation of Core Tools?

wangcarlton commented 2 years ago

@michaelpeng36 Thank you for the reply. For your first question, I've tried to install 4(docker pull --platform=linux/amd64 ubuntu, if I don't add --platform param here, it leads to a E: Unable to locate package azure-functions-core-tools or E: Unable to locate package azure-functions-core-tools-4 error), manually run the docker file commands and download source function code, as you can see, func command works well, but it still shows "Function not implemented". Yes, we are trying to pack frontend, backend(NodeJs function app) in compose file to make this more portable.

Screen Shot 2022-01-14 at 17 25 46 Screen Shot 2022-01-14 at 17 32 33
wangcarlton commented 2 years ago

Btw, I've tried to set terminal "Open using Rosetta", they don't work. However, if I run it locally on the Mac M1 laptop, it works

Screen Shot 2022-01-14 at 23 02 15
wangcarlton commented 2 years ago

This is when I ran those commands, and following https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local to create a sample function on the container, still got the same result

Screen Shot 2022-01-19 at 21 31 51
ejizba commented 2 years ago

I will say I don't think the "Function" mentioned in the error message is an Azure function. If I search "Function not implemented" I find many other instances of that error that seem to be unique to Docker/linux environments when trying to access a file. For example:

https://stackoverflow.com/questions/68455992/docker-compose-on-mac-m1-error-function-not-implemented

https://github.com/docker/for-win/issues/5955

wangcarlton commented 2 years ago

Yeah, that might be the docker simulated container issue on Mac M1. Share this piece of debug info:

Screen Shot 2022-01-20 at 20 39 02
anthonychu commented 2 years ago

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.

wangcarlton commented 2 years ago

@anthonychu Thank you for the updates and please let me know once it's fixed.

Timothy-Pulliam commented 2 years ago

when running in a linux/amd64 container when running on an M1 docker host.

I too am having this problem. Here is the output from func start --debug

Setting unsupported .NET environemt variables (empty string) is not implemented for this platform.
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.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
   at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at Azure.Functions.Cli.Actions.HostActions.StartHostAction.BuildWebHost(ScriptApplicationHostOptions hostOptions, Uri listenAddress, Uri baseAddress, X509Certificate2 certificate) in D:\a\1\s\src\Azure.Functions.Cli\Actions\HostActions\StartHostAction.cs:line 202
   at Azure.Functions.Cli.Actions.HostActions.StartHostAction.RunAsync() in D:\a\1\s\src\Azure.Functions.Cli\Actions\HostActions\StartHostAction.cs:line 360
   at Azure.Functions.Cli.ConsoleApp.RunAsync[T](String[] args, IContainer container) in D:\a\1\s\src\Azure.Functions.Cli\ConsoleApp.cs:line 64
wangcarlton commented 2 years ago

Hey, any updates on this issue? thank you

alexis-franche commented 2 years ago

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

diberry commented 2 years ago

@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?

bonsenz commented 2 years ago

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"]
stephen776 commented 2 years ago

Same issue here as @bon above

cnkeats commented 2 years ago

I am having the same issue - can't build on M1 but works fine for other machines. Commenting in hopes of being notified about a solution.

Codesleuth commented 2 years ago

I'm hitting this same M1 Mac specific issue when trying to set up a custom devcontainer in VSCode with functions core tools running inside the container.

$ func start --verbose --debug
> python3 --version
> python --version
> python3.6 --version
> python3.7 --version
> python3.8 --version
> python3.9 --version
Found Python version 3.9.12 (python3).
languageWorkers:python:defaultExecutablePath is set to python3

                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

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

Setting unsupported .NET environemt variables (empty string) is not implemented for this platform.
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.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
   at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
   at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
   at Azure.Functions.Cli.Actions.HostActions.StartHostAction.BuildWebHost(ScriptApplicationHostOptions hostOptions, Uri listenAddress, Uri baseAddress, X509Certificate2 certificate) in D:\a\_work\1\s\src\Azure.Functions.Cli\Actions\HostActions\StartHostAction.cs:line 205
   at Azure.Functions.Cli.Actions.HostActions.StartHostAction.RunAsync() in D:\a\_work\1\s\src\Azure.Functions.Cli\Actions\HostActions\StartHostAction.cs:line 371
   at Azure.Functions.Cli.ConsoleApp.RunAsync[T](String[] args, IContainer container) in D:\a\_work\1\s\src\Azure.Functions.Cli\ConsoleApp.cs:line 64

Side note: someone typo'd "environment": environemt

Hoping this comment will help gravitate more searches to this issue.

Dockerfile, for reference:

# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.6/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT="3.9-buster"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# Install Rust for building deltalake
RUN su vscode -c "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y" 2>&1

# Install Poetry
RUN su vscode -c "curl -sSL https://install.python-poetry.org | python3 -" 2>&1

# Install Azure Functions Core tools
RUN curl -L 'https://github.com/Azure/azure-functions-core-tools/releases/download/4.0.4483/Azure.Functions.Cli.linux-x64.4.0.4483.zip' -o Azure.Functions.Cli.zip && \
    sudo mkdir -p /opt/func && \
    sudo unzip -d /opt/func Azure.Functions.Cli.zip && \
    sudo chmod +x /opt/func/func && \
    sudo chmod +x /opt/func/gozip && \
    rm Azure.Functions.Cli.zip

ENV PATH="/opt/func:${PATH}"
7hamza commented 2 years ago

Facing same issue here, any updates please ?

invisibleaxm commented 2 years ago

Just when i thought i found a way to develop azure functions with pwsh on Mac M1, i ran into this same issue :). Has anyone been able to find a work-around ?

cretumarius commented 2 years ago

Facing the same issue, any updates on this?

vudzero commented 2 years ago

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"]
pokepoke81 commented 2 years ago

Same issue

zdarovka commented 2 years ago

Same issue as @vudzero

DMegarry commented 2 years ago

I too am having the same issue.. Is there any working being done to solve this?

lucafrost commented 1 year ago

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

  3. Activate new Conda env: conda activate rosetta

  4. 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

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

  6. 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"
      }
      }
      ]
  7. Navigate to the project directory & run pip install -r requirements.txt

    3. Testing that all is A-OK

  8. 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 πŸ€–πŸš€
PabloZaiden commented 1 year ago

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.

lehela commented 1 year ago

I'm also facing the same issue that the func host start command terminates when running inside an amd64 architecture container on my Mac M1.

papakpmartin commented 1 year ago

I think I'm seeing this issue, too.

josteinkirkebak commented 1 year ago

Seeing same issue when trying to run in a devcontainer (Azure Functions & C# - .NET 6 (In-Process)) boilerplate and adding the boilerplate project for httpTrigger.

austingayler commented 1 year ago

Is this issue related to this?

arcogabbo commented 1 year ago

I'm facing the same issue running a node azure function on a docker container, debug infos below: func start --javascript --verbose --debug

ifconfig -a
container-test-1  | > ip link
container-test-1  | 
container-test-1  |                   %%%%%%
container-test-1  |                  %%%%%%
container-test-1  |             @   %%%%%%    @
container-test-1  |           @@   %%%%%%      @@
container-test-1  |        @@@    %%%%%%%%%%%    @@@
container-test-1  |      @@      %%%%%%%%%%        @@
container-test-1  |        @@         %%%%       @@
container-test-1  |          @@      %%%       @@
container-test-1  |            @@    %%      @@
container-test-1  |                 %%
container-test-1  |                 %
container-test-1  | 
container-test-1  | 
container-test-1  | Azure Functions Core Tools
container-test-1  | Core Tools Version:       3.0.4626 Commit hash: N/A  (64-bit)
container-test-1  | Function Runtime Version: 3.9.0.0
container-test-1  | 
container-test-1  | Skipping 'AzureWebJobsScriptRoot' from local settings as it's already defined in current environment variables.
container-test-1  | System.IO.IOException: Function not implemented
container-test-1  |    at System.IO.FileSystemWatcher.StartRaisingEvents()
container-test-1  |    at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
container-test-1  |    at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
container-test-1  |    at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
container-test-1  |    at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
container-test-1  |    at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
container-test-1  |    at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
container-test-1  |    at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
container-test-1  |    at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
container-test-1  |    at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
container-test-1  |    at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
container-test-1  |    at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
container-test-1  |    at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
container-test-1  |    at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
container-test-1  |    at Azure.Functions.Cli.Actions.HostActions.StartHostAction.BuildWebHost(ScriptApplicationHostOptions hostOptions, Uri listenAddress, Uri baseAddress, X509Certificate2 certificate) in D:\a\_work\1\s\src\Azure.Functions.Cli\Actions\HostActions\StartHostAction.cs:line 206
container-test-1  |    at Azure.Functions.Cli.Actions.HostActions.StartHostAction.RunAsync() in D:\a\_work\1\s\src\Azure.Functions.Cli\Actions\HostActions\StartHostAction.cs:line 361
container-test-1  |    at Azure.Functions.Cli.ConsoleApp.RunAsync[T](String[] args, IContainer container) in D:\a\_work\1\s\src\Azure.Functions.Cli\ConsoleApp.cs:line 66
container-test-1 exited with code 1
ctstone commented 1 year ago

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
Manbearpiet commented 1 year ago

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.

slyons commented 1 year ago

Sadly it looks like this is going to continue to be a problem until linux/arm64/v8 is an available platform for mcr.microsoft.com/azure-functions/... containers

garygcd commented 1 year ago

+1

zakpaw commented 1 year ago

Same issue

Blind-Watchmaker commented 1 year ago

+1

calfin-jubelio commented 1 year ago

sundul gan +1

jnsvd commented 1 year ago

We're facing the same issue. Please provide a fix

sjasperse commented 1 year ago

This looks like it should be as simple as disabling the file monitoring option, but I can't quite figure it out.

The FileMonitoringService enables it's watchers based on if ScriptJobHostOptions.FileWatchingEnabled is set to true. https://github.com/Azure/azure-functions-host/blob/51b519c6e21e423e745d8a9a9d565b55a071ae6c/src/WebJobs.Script.WebHost/FileMonitoringService.cs#L155

ScriptJobHostOptions.FileWatchingEnabled is set to true based on if ScriptApplicationHostOptions.IsFileSystemReadOnly is true. https://github.com/Azure/azure-functions-host/blob/51b519c6e21e423e745d8a9a9d565b55a071ae6c/src/WebJobs.Script/Config/ScriptJobHostOptionsSetup.cs#L65

ScriptApplicationHostOptions is created and bound to the configuration section AzureFunctionsWebHost. https://github.com/Azure/azure-functions-host/blob/7b828af7614660bc4b902f5e931517a5352f0968/src/WebJobs.Script.WebHost/Configuration/ScriptApplicationHostOptionsSetup.cs#L43

So it SHOULD be as simple as setting an environment variable AzureFunctionsWebHost__IsFileSystemReadOnly=True in order to bypass the file system monitoring - but I can't get it to pick up the value.

CHarnel commented 1 year ago

Facing the same issue as well, please provide a solution or at least a workaround

sjasperse commented 1 year ago

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

3issamben commented 1 year ago

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

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

lks-hrsch commented 1 year ago

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

@3lissamben, can you share your setup I try to get this working too, but my docker build is stuck at installing the dependencies with pip.

sasukeh commented 1 year ago

@3issamben I've tried your suggestion but I faced additional issue with following one.

image

It seems run a function when I saw that on console of docker desktop. but I couldn't connect terminal from vscode. Do you have any suggestion for this?

daniel-arrick commented 1 year ago

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

This works, thanks

ivaylo-infostrux commented 1 year ago

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!

ReluXingZeng commented 11 months ago

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.

rezunalex commented 10 months ago

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?

sasukeh commented 10 months ago

Even M1 and M2, It works for me with Rosetta and arm64 and latest Mac version.

❯ uname -a 
Darwin Mac-mini.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:21:53 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6020 arm64
❯ arch
arm64
❯ func --version
4.0.5198
γ‚Ήγ‚―γƒͺγƒΌγƒ³γ‚·γƒ§γƒƒγƒˆ 2023-08-17 12 21 39

Is there additional issue?

UrielMaD commented 8 months ago

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/

This also helped me!

Put in your dockerfile FROM --platform="linux/amd64" ... then make sure that Docker is updated, enable rosetta in docker and it will work!