How to add a reference of "System.ServiceModel" from Azure Function?

1.8k views Asked by At

I am calling an SOAP service from my Azure Function, and for that I need to add reference of System.ServiceModel assembly. I am able to add other dependencies using Nuget, but as this particular assembly is a framework assembly, so not sure how can I add reference of this assembly in my Azure function.

Currently I am getting following compilation error:

error CS0012: The type 'ClientBase<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Copying that assembly to bin folder using Kudu would be the last thing I would want to try :)

Any suggestions on a better approach for this?

Thanks and Regards,

Nirman

1

There are 1 answers

0
Rajan Panneer Selvam On BEST ANSWER

https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-csharp

You can refer the system assemblies by #r "AssemblyName" directive

#r "System.Web.Http"

using System.Net;
using System.Net.Http;
using System.Threading.Tasks;

public static Task Run(HttpRequestMessage req, TraceWriter log)