title: Running .Net Core based Azure Function in Docker Container on Apple Silicon
body: <p>I am trying to run a .Net Core based Azure Function inside a Docker container on a M1 Macbook without success so far.</p>
  <p>Originally I used the Azure Function Core Tools CLI to create the function with the following command: <code>func init LocalFunctionsProject --worker-runtime dotnet --docker</code> which created the following Dockerfile.</p>
  <pre><code>FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS installer-env
  
  COPY . /src/dotnet-function-app
  RUN cd /src/dotnet-function-app &amp;&amp; \
      mkdir -p /home/site/wwwroot &amp;&amp; \
      dotnet publish *.csproj --output /home/site/wwwroot
  
  # To enable ssh &amp; remote debugging on app service change the base image to the one below
  # FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
  FROM mcr.microsoft.com/azure-functions/dotnet:3.0
  ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
      AzureFunctionsJobHost__Logging__Console__IsEnabled=true
  
  COPY --from=installer-env [&quot;/home/site/wwwroot&quot;, &quot;/home/site/wwwroot&quot;]
  </code></pre>
  <p>Building the Docker image and running as Container works just fine on a amd based machine. In the meanwhile I got myself a M1 Macbook on which running the Azure Function inside a Docker Container does not work anymore. It gives me the following exception:</p>
  <pre><code>WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
  Unhandled exception. 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.&lt;.ctor&gt;b__1_0()
     at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
     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&amp; hostingStartupErrors)
     at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
     at Microsoft.Azure.WebJobs.Script.WebHost.Program.BuildWebHost(String[] args) in /src/azure-functions-host/src/WebJobs.Script.WebHost/Program.cs:line 35
     at Microsoft.Azure.WebJobs.Script.WebHost.Program.Main(String[] args) in /src/azure-functions-host/src/WebJobs.Script.WebHost/Program.cs:line 25
  qemu: uncaught target signal 6 (Aborted) - core dumped
  </code></pre>
  <h2>What I tried so far</h2>
  <ol>
  <li>Forcing Docker to use amd based base image by adding <code>--platform=linux/amd64</code> to the FROM section of the first stage in the Dockerfile which gives me the following error message:</li>
  </ol>
  <pre><code>&gt; [installer-env 3/3] RUN cd /src/dotnet-function-app &amp;&amp;     mkdir -p /home/site/wwwroot &amp;&amp;     dotnet publish *.csproj --output /home/site/wwwroot:                               
  #9 3.258 Microsoft (R) Build Engine version 16.7.2+b60ddb6f4 for .NET
  #9 3.258 Copyright (C) Microsoft Corporation. All rights reserved.
  #9 3.258 
  #9 3.441 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
  #9 3.456 Segmentation fault
  ------
  executor failed running [/bin/sh -c cd /src/dotnet-function-app &amp;&amp;     mkdir -p /home/site/wwwroot &amp;&amp;     dotnet publish *.csproj --output /home/site/wwwroot]: exit code: 139
  </code></pre>
  <ol start="2">
  <li>Changing the base image of the second stage to <code>mcr.microsoft.com/azure-functions/dotnet:3.0-arm32v7</code> which gave me the following error:</li>
  </ol>
  <pre><code>WARNING: The requested image's platform (linux/arm) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
  A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders
  </code></pre>
  <h2>Conclusion</h2>
  <p>My personal conclusion from how I understand the problem is that probably it will not work on my M1 machine unless there is a dedicated azure-function/dotnet image for arm64 v8 machines. If I am completely wrong, please hint me to the right direction.</p>