0

We have an Azure Function running on a Linux host.
Our app is a netcoreapp3.1. It runs fine, except for one issue which I can't explain.
The csproj file has always been configured like this (only a snippet):

<PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
    <UserSecretsId>...</UserSecretsId>
    <RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
  </PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Cloud.Asset.V1" Version="2.6.0" />
</ItemGroup>

There are many other packages, but this one is the one with the issue. On Windows everything works fine, all good. On Linux (or WSL2) the app also builds fine, the Functions Host starts and all seems well, until we hit code that uses the Google.Cloud.Asset.V1 package. This package references Grpc.Core and the code then fails with

System.Private.CoreLib: Exception while executing function: inventory. Grpc.Core: Error loading native library. Not found in any of the possible locations: /mnt/c/development/app/App.Functions/bin/Debug/netcoreapp3.1/bin/libgrpc_csharp_ext.x64.so,/mnt/c/development/app/App.Functions/bin/Debug/netcoreapp3.1/bin/runtimes/linux/native/libgrpc_csharp_ext.x64.so,/mnt/c/development/app/App.Functions/bin/Debug/netcoreapp3.1/bin/../../runtimes/linux/native/libgrpc_csharp_ext.x64.so.

It doesn't seem to make munch sense to me because this used to work, but nothing in the csproj changed recently, apart from other dependencies that were added, but are unrelated to this.
Checking in bin/Debug/netcoreapp3.1/bin/runtimes there's no linux only Windows. VS Code build result

I do however see this directory here, which doesn't seem to be in the search path in the error message though. This is bin/Debug/netcoreapp3.1/runtimes.
runtimes

Does anybody know how I can get this to work again?
I tried adding <RuntimeIdentifier> or <RuntimeIdentifiers> into the csproj, but that didn't change anything.

12
  • 1
    The package is broken, you need to contact the package maintainers to fix it.
    – Ian Kemp
    Jan 18, 2021 at 12:34
  • @IanKemp: I see no sign that it's broken, in that it works on Linux in other environments. We've had issues with Azure Functions before in terms of managing dependencies. I don't know what Azure Functions is doing differently to a regular environment.
    – Jon Skeet
    Jan 18, 2021 at 13:13
  • @JonSkeet I parsed the question as "it used to work on Azure Functions but no longer does", how did you parse it? Obviously I'm missing something here...
    – Ian Kemp
    Jan 18, 2021 at 14:11
  • @IanKemp: Yes, the same package (and indeed the same version) used to work on Azure Functions but no longer does. That suggests to me that it's Azure Functions which has changed and broken things - so that suggests it's not the package that's broken. If you have reason to believe that it's genuinely the package's fault, I'd love to hear more details, as I'd like to improve things. But I really suspect it's an Azure Functions deployment issue.
    – Jon Skeet
    Jan 18, 2021 at 14:19
  • 1
    I've reproduced this myself in Docker now - it looks like the problem is that the Azure Functions SDK (or runtime?) creates a local copy of the DLLs it needs inside a nested "bin" directory, but doesn't copy the native libraries. Will continue investigating, but probably tomorrow...
    – Jon Skeet
    Jan 18, 2021 at 16:08

1 Answer 1

4

It looks like this is a problem that was fixed in Grpc.Core 2.34.0 (by this commit, I believe). If you add an explicit dependency on Grpc.Core 2.34.0, like this:

<PackageReference Include="Grpc.Core" Version="2.34.0" />

... that seems to fix it. I still don't know why the runtime was copied into the "old" expected place for Windows but not for Linux - that feels like it's an Azure Functions SDK issue somehow. But with Grpc.Core 2.34.0, the native extension loader "knows" where to find it in the parent bin/runtimes directory instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.