21

The documentation says that you can put a DLL in a bin folder and reference it using a special #r syntax, however in the Azure portal I cannot find how to upload these DLLs. Is this possible, and if so, how is that supposed to be accomplished?

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
Josh
  • 6,944
  • 8
  • 41
  • 64
  • It looks like the questions are the same, however the answers are very different. That answer doesn't seem to apply, but the link in it mentions what I would consider the correct answer... – Josh Apr 12 '16 at 19:01

5 Answers5

31

This is possible.

You can use Kudu to upload your binaries:

  1. Open the app's Kudu portal. If your Functions App's URL is samplefunctions.azurewebsites.net, then go to samplefunctions.scm.azurewebsites.net.

  2. Click on the Debug console menu and select PowerShell. This will open up a PowerShell console plus a file explorer. Navigate to D:\home\site\wwwroot.

  3. There you should see a folder which is named after your existing function. Navigate to that folder and drag-n-drop your binaries inside bin folder.

  4. Now you can use them with #r directive.

I think you should also be able to configure the continuous deployment of your libraries to Functions (e.g. from a Git repo). Go to Function app settings -> Configure Continuous Integration.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
  • 2
    So is Azure Functions in C# using ScriptCS under the hood? – MiddleTommy Apr 29 '16 at 02:07
  • I have done this but it throws error : Metadata file '' could not be found. Any idea? – shwetaOnStack May 09 '16 at 12:39
  • 1
    This no longer works, I get: `run.csx(1,1): error CS0006: Metadata file 'Test.dll' could not be found` – Josh Aug 23 '16 at 12:36
  • 8
    After more testing, I discovered that I missed the `bin` folder step. After navigating to Kudu as described in the answer: 1. Create a `bin` folder **within** the function folder. 2. Upload the DLL files into that `bin` folder. 3. Use `#r "Test.dll"` to reference them within the csx file. For example: `D:\home\site\wwwroot\test1\bin\Test.dll` where "test1" is the function name. – Josh Aug 23 '16 at 12:43
3

Azure functions now has runtime support for precompiled functions. https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/

You’ll need to use a web project which will provide the full development experience of IntelliSense, local debugging, and publishing to Azure. The instructions above detail how.

Irwin
  • 12,551
  • 11
  • 67
  • 97
1

You're able to deploy your functions that has some external references just doing the deploy by Visual Studio Functions Tools.

Just configure your Azure account in your visual studio deployment settings, for your azure functions and play deploy. All references will be there in your Function App on azure.

1

You can use Octopus Deploy (Website deployment step) to deploy a function.

The folder structure of the nuget package pushed to octopus deploy should be:

nuget_package.nupkg
    |--bin
        |--*.dll
    |--run.csx 
    |--function.json
Tany
  • 1,252
  • 14
  • 30
1

You can add assembly reference with a relative path.

In portal.azure.com -> function apps, on the right hand side, View Files -> upload the dll (eg: YourDllName.dll).

In run.csx, enter #r "./YourDllName.dll"

PCoder
  • 11
  • 2