question

Raf avatar image
Raf asked

How to run Azure Functions locally on VS Code using Apple Silicon (M1 chip)?

Hi there,

I've been trying to run my Azure Functions locally for a lot longer than I'd like to admit and now I find myself in desperate need of help.

I had no problems running the functions locally on the my old Mac (Intel) but now that i switched to the new M1 version with arm64 architecture, I find this error when i try to build:

/Users/raf/.nuget/packages/microsoft.net.sdk.functions/3.0.3/build/Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Failed to load /usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.3/libhostpolicy.dylib, error: dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.3/libhostpolicy.dylib, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.3/libhostpolicy.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/libhostpolicy.dylib' (no such file), '/usr/lib/libhostpolicy.dylib' (no such file) [/Users/raf/UnityProjects/Fight/Azure/Azure.csproj]
/Users/raf/.nuget/packages/microsoft.net.sdk.functions/3.0.3/build/Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : An error occurred while loading required library libhostpolicy.dylib from [/usr/local/share/dotnet/shared/Microsoft.NETCore.App/3.0.3] [/Users/raf/UnityProjects/Fight/Azure/Azure.csproj]
/Users/raf/.nuget/packages/microsoft.net.sdk.functions/3.0.3/build/Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :  [/Users/raf/UnityProjects/Fight/Azure/Azure.csproj]
/Users/raf/.nuget/packages/microsoft.net.sdk.functions/3.0.3/build/Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Metadata generation failed. [/Users/raf/UnityProjects/Fight/Azure/Azure.csproj]

I've tried installing different versions of .NET and even considered migrating the functions version in Azure to v4 but as this is beyond my pay-grade it only lead me to more errors.

Anything that could point me to the right path would be much appreciated!

Thanks!

sdksCloudScriptapple
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Made Wang avatar image
Made Wang answered

Have you successfully configured the environment and implemented the examples in Create a C# function using Visual Studio Code - Azure Functions | Microsoft Docs? If you encounter some problems during this process, it is recommended that you go to the Azure Function community for professional support.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

nwhitmont avatar image
nwhitmont answered

@Raf -- Did you install the Azure Functions Core Tools library for macOS at the system level?

It's recommended to install via homebrew.

brew tap azure/functions
brew install azure-functions-core-tools@4

# if upgrading on a machine that has 2.x or 3.x installed:
brew link --overwrite azure-functions-core-tools@4

See: Install the Azure Functions Core Tools

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Raf avatar image Raf commented ·

Hi @nwhitmont, Thanks for the reply.

I did try upgrading to v4 as well as to dotnet6.0 but for the life of me I was not able to run the build successfully and ended up lost in a forever going loophole of more errors as I wasn't sure how to integrate it.

Unfortunately, I ended up returning my Mac as I wasn't able to spend more time trying to make it work. (went back to the intel based Mac as it already worked) I do appreciate the reply though!

0 Likes 0 ·
nwhitmont avatar image
nwhitmont answered

@Raf -- Did you try with .NET SDK 6.0.202 for macOS Arm64?

You can download the installer here: https://dotnet.microsoft.com/en-us/download/dotnet/6.0

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.