Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Azure Function in Dll doesn't work in Azure (but in emulator)

Because I want an Azure Function totally compiled before deploying, and because I want to have all the benefits of refactorings (automatic renamings) before deploying, I want to get rid of the Csx file and use a Dll.

And I want all my code to be in .Dll - fully compiled.

So it works fine in the local emulator, but I can't get it to work in Azure

I always get the same error message in the log file :

MailSenderFunction: Unable to determine the primary function script.
Try renaming your entry point script to 'run' (or 'index' in the case of     Node),
or alternatively you can specify the name of the entry point script explicitly by adding a 'scriptFile' property to your function metadata.

And I don't see my function appear in the Function App in the portal.

function.json :

{
  "disabled": false,
  "scriptFile": "./bin/MailSenderFunctionLib.dll",
  "entryPoint": "MyCompany.MailSenderFunctionLib.MailSenderFunctionProcessor.RunCsxLess",
  "bindings": [
    {
      ...
    }
  ]
}

The Dll code :

namespace MyCompany.MailSenderFunctionLib
{
  public class MailSenderFunctionProcessor
  {
    public static void RunCsxLess(Mail mail)
    {
      // ...
    }
}

The dll is in the bin directory of the function, not the bin directory of the App Function

Any Idea ?

like image 647
Emmanuel DURIN Avatar asked Jan 17 '26 21:01

Emmanuel DURIN


1 Answers

This will be fully supported on the next release of the runtime ( > 1.0.10690).

You can find more information about that enhancement here

The reason you observed the different behavior when running locally is because the CLI preview is (unfortunately) ahead of the hosted environment at this point and using the new runtime bits. We're changing the process to ensure those releases are in lockstep with each other moving forward.

like image 184
Fabio Cavalcante Avatar answered Jan 19 '26 11:01

Fabio Cavalcante



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!