Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run Azure Durable Functions on Mac M2 PRO #2446

Closed
apavate opened this issue Apr 12, 2023 · 12 comments
Closed

Cannot run Azure Durable Functions on Mac M2 PRO #2446

apavate opened this issue Apr 12, 2023 · 12 comments
Assignees

Comments

@apavate
Copy link

apavate commented Apr 12, 2023

Description

When trying to create and run a new Azure Durable Function (.NET 7 | Isolated), I am unable to run it successfully.

A host error has occurred during startup operation '8643db33-586e-4c53-92d0-476fbeb08331'.
[2023-04-12T20:49:22.183Z] Grpc.Core: Error loading native library. Not found in any of the possible locations: /Users/apavate/Documents/Visual Studio Projects/OpenAIApps/DocumentUnderstanding/bin/Debug/net7.0/.azurefunctions/libgrpc_csharp_ext.arm64.dylib,/Users/apavate/Documents/Visual Studio Projects/OpenAIApps/DocumentUnderstanding/bin/Debug/net7.0/.azurefunctions/runtimes/osx-arm64/native/libgrpc_csharp_ext.arm64.dylib,/Users/apavate/Documents/Visual Studio Projects/OpenAIApps/DocumentUnderstanding/bin/Debug/net7.0/.azurefunctions/../../runtimes/osx-arm64/native/libgrpc_csharp_ext.arm64.dylib.
Value cannot be null. (Parameter 'provider')

NOTE: JavaScript issues should be reported here: https://github.com/Azure/azure-functions-durable-js

Expected behavior

Should run without any issues.

Actual behavior

Does not run.

Relevant source code snippets

Boiler-plate code generated when a new project is created inside Visual Studio for Mac.

### Known workarounds
> Provide a description of any known workarounds you used.

### App Details

- **Durable Functions extension version (e.g. v1.8.3)**:
- **Azure Functions runtime version (1.0 or 2.0)**:
- **Programming language used**:

### Screenshots
> If applicable, add screenshots to help explain your problem.

### If deployed to Azure
> We have access to a lot of telemetry that can help with investigations. Please provide as much of the following information as you can to help us investigate!

- **Timeframe issue observed**:
- **Function App name**:
- **Function name(s)**:
- **Azure region**:
- **Orchestration instance ID(s)**:
- **Azure storage account name**:

> If you don't want to share your Function App or storage account name GitHub, please at least share the orchestration instance ID. Otherwise it's extremely difficult to look up information.
@davidmrdavid
Copy link
Contributor

Hi @apavate. I believe you may be experiencing the issue described here. Can you please review that guidance and let me know if that worked for you?

@davidmrdavid davidmrdavid added the Needs: Author Feedback Waiting for the author of the issue to respond to a question label Apr 18, 2023
@apavate
Copy link
Author

apavate commented Apr 19, 2023

@davidmrdavid
I have tried it and failed miserably. I think that's mainly because there aren't any clear instructions.
Since this is a known issue, can you supply some clear step-by-step instructions so I can try it again?

@ghost ghost added Needs: Attention 👋 and removed Needs: Author Feedback Waiting for the author of the issue to respond to a question labels Apr 19, 2023
@vdboots
Copy link

vdboots commented Apr 20, 2023

For now as a workaround:

Add the package reference
<PackageReference Include="Contrib.Grpc.Core.M1" Version="2.41.0" />

And add this to your csproj.
<Target Name="CopyGrpcNativeAssetsToOutDir" AfterTargets="Build"> <ItemGroup> <NativeAssetToCopy Condition="$([MSBuild]::IsOSPlatform('OSX'))" Include="$(OutDir)runtimes/osx-arm64/native/*" /> </ItemGroup> <Copy SourceFiles="@(NativeAssetToCopy)" DestinationFolder="$(OutDir).azurefunctions/runtimes/osx-arm64/native" /> </Target>

This will copy the needed file to the folder required. Until there is a fix

@apavate
Copy link
Author

apavate commented Apr 21, 2023

I want to update the instructions to make it easy for other developers.

  1. Add the Nuget package Contrib.Grpc.Core.M1 to the Azure Function Project by either using the Nuget Package Manager or by just adding the following line to the .csproj file.
    <PackageReference Include="Contrib.Grpc.Core.M1" Version="2.41.0" />

  2. Add the following line to the .csproj file right before the last </Project> tag.
    <Target Name="CopyGrpcNativeAssetsToOutDir" AfterTargets="Build"> <ItemGroup> <NativeAssetToCopy Condition="$([MSBuild]::IsOSPlatform('OSX'))" Include="$(OutDir)runtimes/osx-arm64/native/*" /> </ItemGroup> <Copy SourceFiles="@(NativeAssetToCopy)" DestinationFolder="$(OutDir).azurefunctions/runtimes/osx-arm64/native" /> </Target>

  3. Run the project and it should work!

Solution Credits: @vdboots

@apavate apavate closed this as completed Apr 21, 2023
@Hipster74
Copy link

Ok, the workaround looked promising, and my durable function compiled and started, but it crashes when invoking the function via http get call, sigh.

exception: System.AggregateException: One or more errors occurred. (Status(StatusCode="Unknown", Detail="Exception was thrown by handler.")) ---> Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="Exception was thrown by handler.")

@apavate
Copy link
Author

apavate commented Apr 21, 2023

Ok, the workaround looked promising, and my durable function compiled and started, but it crashes when invoking the function via http get call, sigh.

exception: System.AggregateException: One or more errors occurred. (Status(StatusCode="Unknown", Detail="Exception was thrown by handler.")) ---> Grpc.Core.RpcException: Status(StatusCode="Unknown", Detail="Exception was thrown by handler.")

Works perfectly for me on Apple Macbook Pro (M2 Pro). Tried creating both .net6 in-process function and .net7 isolated function, and it works in both cases.

@apavate apavate reopened this Apr 21, 2023
@Hipster74
Copy link

Yes @apavate , did stupid mistake, it works for me as well on M1 Mac, thanks for the workaround!

@jviau
Copy link
Contributor

jviau commented Apr 27, 2023

This issue: Azure/azure-functions-host#9235 is aiming to holistically fix this, as durable will then switch to AspNetCore implementation of gRPC in the host.

@davidmrdavid
Copy link
Contributor

Just as a heads up, we've surfaced the instructed provided here by @apavate and @vdboots in the DF isolated SDK repo: microsoft/durabletask-dotnet#148. Thanks for your contribution here :).

@apavate
Copy link
Author

apavate commented Apr 27, 2023

Just as a heads up, we've surfaced the instructed provided here by @apavate and @vdboots in the DF isolated SDK repo: microsoft/durabletask-dotnet#148. Thanks for your contribution here :).

Thank you!

@mxrnx
Copy link

mxrnx commented Apr 9, 2024

Yes @apavate , did stupid mistake, it works for me as well on M1 Mac, thanks for the workaround!

Hi @Hipster74 , would you mind sharing what your mistake was? I am facing the exact same issue.

Figured it out after hours, so for anyone else stumbling upon this issue in the future: for me the (stupid) issue was that I had excluded the durable function in my host.json.

@boylec
Copy link

boylec commented Jun 12, 2024

I'm actually not on M1/M2, I'm on an Intel Mac on .NET 8 having this issue.

For me the following seems to be getting me by for now...

  1. dotnet add package Grpc.Core
  2. add target to project (note osx-x64 rather than osx-arm64 and slightly different paths than the other examples on here)
  <Target Name="CopyGrpcNativeAssetsToOutDir" AfterTargets="Build">
    <ItemGroup>
      <NativeAssetToCopy Condition="$([MSBuild]::IsOSPlatform('OSX'))"
        Include="$(OutDir)runtimes/osx-x64/native/*" />
    </ItemGroup>
    <Copy SourceFiles="@(NativeAssetToCopy)"
      DestinationFolder="$(OutDir)bin/runtimes/osx-x64/native" />
  </Target>

If I didn't do the above when I run my app it looks for the Grpc.Core assets in locations where they are not being output to by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants