Is it possible to use an In-Proc COM DLL with Azure Functions?
I am migrating my web service to Azure Functions. One of the components has a dependency on a legacy 32-bit COM DLL. This would normally require the DLL to be regsvr32-ed on the system where it will be used. As that seems not possible with Azure Functions is it possible to use such legacy implementations?
Or would it be necessary to revert to a classic cloud service to support this? (My preference would be use the Consumption service plan and benefit from "serverless" architecture.)
Steps:
Error log reports exception:
Could not load file or assembly 'Interop.MyCOMLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Exception while executing function: Legacy Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Legacy ---> System.IO.FileNotFoundException : Could not load file or assembly 'Interop.MyCOMLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. at async Functions.Legacy.Run(HttpRequestMessage req,TraceWriter log) at System.Runtime.CompilerServices.AsyncTaskMethodBuilder 1.Start[TStateMachine](TStateMachine& stateMachine) at Functions.Legacy.Run(HttpRequestMessage req,TraceWriter log) at lambda_method(Closure ,Legacy ,Object[] )
at Microsoft.Azure.WebJobs.Host.Executors.TaskMethodInvoker 2.InvokeAsync(TReflected instance,Object[] arguments) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker 2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) End of inner exception
Also, if I go to the solution's Dependencies | COM then select the Interop.Lib and select to Embed Interop Types then with this change, after publish, on calling the publushed function:
"Retrieving the COM class factory for component with CLSID {D84F92D7-FFFF-4C16-B939-EC98E3A6EBC0} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."
Thus, the challenge is how to register the COM classes with Azure Functions?
Entity Framework can be used in . NET 5 Azure Functions for many different use cases, for example, using it to connect to a database like Azure SQL Database, MySQL or any other accessible and supported databases.
Open IntelliJ IDEA's Welcome dialog, select New Project to open a new project wizard, then select Azure Functions. Select Http Trigger, then click Next and follow the wizard to go through all the configurations in the following pages. Confirm your project location, then click Finish.
The HTTP trigger lets you invoke a function with an HTTP request. You can use an HTTP trigger to build serverless APIs and respond to webhooks. The default return value for an HTTP-triggered function is: HTTP 204 No Content with an empty body in Functions 2.
It seems that it is not possible to run regsvr32 on function app platform, when running command on Kudu console, it shows "Access Denied".
The solution is to:
1- Create small web service that use COM lib and consume its functionality and host this app on windows VM.
2- Host other part of your you code in function app and instead of reference the function APP to COM , you can call the hosted web service (and pass whatever parameters you want )
Or simply you can deploy full code on VM and don’t use Function APP.
(Thanks to Microsoft support for this answer).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With