This article shows how to automatically create local function app classes that can be called by logic app .
We'll also talk about the use of T4 for code generation and provide a practical example with a sample web service.
WorkflowActionTrigger is a type of function app triggers that can be invoked by logic app which called Local Function App
Image
For more information, visit .NET Framework Custom Code for Azure Logic Apps (Standard) Reaches General Availability (microsoft.c....
Integrating web services into a .NET project can be done using tools like ServiceUtil and wsdl.exe.
In my POC I will talk only about ServiceUtil which it will create reference.cs class and it is available in visual studio 2022
For detailed information on wsdl.exe, visit WSDL and Service Contracts.
For detailed information on ServiceUtil (Svcutil.exe), visit ServiceModel Metadata Utility Tool (Svcutil.exe).
https://learn.microsoft.com/en-us/dotnet/core/additional-tools/wcf-web-service-reference-guide
T4 (Text Template Transformation Toolkit) is a powerful tool for generating C# code. It can be run using TextTransform.exe. Here's how to do it:
The template that I have created WSProxyGenerator.tt will open the Function App DLL using Reflection then scan it for all interfaces with attribute named ServiceContractAttribute
public class AddAsyncLogicAppProxy
{
private readonly ILogger<AddAsyncLogicAppProxy> logger;
public AddAsyncLogicAppProxy(ILoggerFactory loggerFactory)
{
logger = loggerFactory.CreateLogger<AddAsyncLogicAppProxy>();
}
[FunctionName("AddAsyncLogicAppProxy")]
public Task<Int32> Run([WorkflowActionTrigger] string endpointAddress, Int32 a, Int32 b)
{
var _binding = new BasicHttpsBinding();
var _address = new EndpointAddress(endpointAddress);
using (var proxy = new CalculatorWebServiceSoapClient(_binding, _address))
{
var result = proxy.AddAsync(a, b);
return result;
}
}
}
Since the template expect the Dll to be exist then fist you need to build your Function App first to generate the Dll.
You need to locate the file TextTransform.exe which exists.
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\IDE\TextTransform.exe
Modify the T4 file and change Dll path inside the template then save it.
string dllPath = "......fa.dll";
Then run the below command to generate the c# file that contains all classes.
TextTransform.exe" "path_to\WSProxyGenerator.tt"
#first Build to get the Dll
dotnet build FunctionApp.csproj
#generate the proxy class CS file
TextTransform.exe" "path_to\WSProxyGenerator.tt"
#Build to get the Dll again to get the proxy generated
dotnet build FunctionApp.csproj
To verify that everything worked as expected.
Make sure that you have the function.json in the lib folder in logic app.
then Open logic app designer and make sure that you can see the new Functions.
To demonstrate the concepts, we will use a sample web service. The logic app will call the following web service: Calc.asmx.
from http://ecs.syr.edu/faculty/fawcett/Handouts/cse775/code/calcWebService/Calc.asmx
To access the complete repository with all the necessary files and detailed instructions, visit the GitHub repository:
logic-app-workspace-with-web-service-client-generator
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.