Skip to content

Repository.Clone() not working within a Azure Function (Unable to load DLL 'git2-6311e88') #1574

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

Closed
anthonyhuebers opened this issue May 16, 2018 · 8 comments

Comments

@anthonyhuebers
Copy link

I'm trying to clone repositories in an Azure Function to determine if repositories are up and cloneable.

The following code does work in a Console App (.NET Core) project but not in an Azure function project

var tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("D"));
Directory.CreateDirectory(tempPath);

var cloneDirectory = Path.Combine(tempPath, "clone");

var repositoryLocation = @"https://github.com/anthonyhuebers/GitClone.git";
var cloneResult = Repository.Clone(repositoryLocation, cloneDirectory, new CloneOptions());

In an Azure function project i get the following exception message:

The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.

With inner exception:

Unable to load DLL 'git2-6311e88': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Any idea why it's not working? You can reproduce the problem by checking my git repository: https://github.com/anthonyhuebers/GitClone. I'm using LibGit2Sharp 0.25.0

@ethomson
Copy link
Member

This is a dup of #1533. Fundamentally, we do not know if Azure Functions supports native method calls (PInvoke) - and if it does - where or how to load those libraries. If you have information or know how to debug this, that would be helpful.

@anthonyhuebers
Copy link
Author

This morning I solved the problem. I used an Azure Function v1 (.NET Framework instead of .NET Standard) with the LibGit2Sharp 0.21.0.176. When you include the native binary in the release it is working!

@ethomson
Copy link
Member

Thanks for this information, @anthonyhuebers.

@helizabethwhite
Copy link

I was running into a similar problem (albeit with a different git2-xxxx hash) and found that I had also been using an Azure Function v1. Trying with an Azure Function v2 fixed it 👍

@ethomson
Copy link
Member

Thanks for the info @helizabethwhite. Closing this since we seem to
Have a solution.

@ethomson ethomson reopened this Jan 15, 2019
@ethomson
Copy link
Member

(Oops it was already closed. In that case I’m reopening it accidentally so that I can dramatically close it again.)

@juhankki
Copy link

@anthonyhuebers @helizabethwhite
How did you get this to work?

I get the same error using Functions Runtime 2.0
I've also tried older versions, different dotnet core sdk's, and both 32- and 64-bit architectures, but still get that 'Unable to load DLL 'git2-xxxx'' error.

@juhankki
Copy link

I think I figured it out.
Runtime needs to be set to win-x64 in publishing settings (in addition to runtime setting in Azure)

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

No branches or pull requests

4 participants