How do you include references to external assemblies in Azure Functions

后端 未结 1 1945
日久生厌
日久生厌 2021-02-07 22:57

I tried the following:

using System;
using Newtonsoft.Json
using Newtonsoft.Linq

public static void Run(string myEventHubMessage, out string document, TraceWrit         


        
1条回答
  •  北海茫月
    2021-02-07 23:41

    Steve,

    .NET Framework assemblies and a few "shared" assemblies may be added with the following syntax:

    #r "AssemblyName"
    

    So, for JSON.NET, you can use:

    #r "Newtonsoft.Json"
    

    Once the reference is added, then you can add your using statements as you would in a regular C# project/file:

    using Newtonsoft.Json;
    

    So, in summary, you need to add a reference to the assemblies you want to use, and import the namespaces exposed by that assembly so you can use its types. This is similar to what you'd do in Visual Studio, where you add the assembly reference and then add your using statements where you need them.

    I hope this helps!

    0 讨论(0)
提交回复
热议问题