Update: Resolved: used VS 2022 to build/pack/deploy to Azure and it worked (Installed Nuget Q16-AnyCPU)
Want to add Azure function that converts images. I successfully created it on my Win Server 2019 x64/Visual Studio 2022 Console App (.NET 6). But I cannot compile it in Azure function: if I use these references ("Q16-AnyCPU"):
#r "Magick.NET.Core.dll"
#r "Magick.NET-Q16-AnyCPU.dll"
then I get errors like
"Unable to load DLL 'Magick.Native-Q16-x64.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)"
or
"Unable to load DLL 'Magick.Native-Q16-x86.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)"
I found how to upload custom DLLs to Azure (I found them in "runtimes" folder in my desktop project) and added these libraries to bin folder:
and now here they are in Azure:
but when I reference them I get different error:
\bin\Magick.NET-Q16-x86.Native.dll' could not be opened -- PE image doesn't contain managed metadata.
I also tried to rebuild and replace DLLs for x86/x64 architecture, and tried to change x64/x86 in Azure Platform settings..
Here is a simplified code-snippet from my Azure Function (compilation fails when it meets MagickImage object ):
#r "Magick.NET.Core.dll"
#r "Magick.NET-Q16-AnyCPU.dll"
//#r "Magick.Native-Q16-x86.dll" // \bin\Magick.NET-Q16-x86.Native.dll' could not be opened -- PE image doesn't contain managed metadata.
//#r "Magick.Native-Q16-x64.dll" // Unable to load DLL 'Magick.Native-Q16-x64.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
//#r "Magick.NET-Q8-x64.Native.dll" // \bin\Magick.NET-Q8-x64.Native.dll' could not be opened -- PE image doesn't contain managed metadata.
#r "Newtonsoft.Json"
using ImageMagick;
using System.Net;
using System.Text;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
try{
using (MagickImage image = new MagickImage()) // <-------- here is compilation error in Azure Function
{
}
} catch(Exception ex) {
log.LogWarning(ex.InnerException.Message);
}
return new OkObjectResult("sample");
}
How to reference MagickImage and use it in C# project in Azure Function?..
Steps to Reproduce
Created .NET 6 Azure Function, paste code-snippet there and try to Test/Run