.NET Framework Custom Code - Calling Existing Assemblies
Published Jun 26 2023 06:58 AM 3,121 Views
Microsoft

We recently announced the public preview of .NET Framework Custom Code Extensibility for Azure Logic Apps (Standard). In that post, we discussed how to author new code and debug it. We now want to expand upon that scenario and discuss how we can call an existing assembly from our custom code project.

 

For organizations who have previously made investments in .NET Framework code, they want to bring these investments forward into Azure Logic Apps (Standard). Perhaps you have a helper assembly that you previously called from BizTalk that performs some specific business logic or data transformation. This assembly would be an ideal candidate to bring into the cloud. In this blog post, we are going to discuss exactly how you can do that.

 

For Logic Apps to call .NET Framework custom code, there is specific plumbing that needs to exist within the custom code for this to happen. More specifically, we have implemented a WorkflowActionTrigger extension, and we require you to decorate a method by providing a FunctionName.

 

KentWeareMSFT_0-1687299411833.png

These requirements prevent you from directly calling a referenced assembly directly from a Logic Apps workflow. But, the good news is that you can "wrap" your existing assemblies quite easily so that they can participate in your Logic Apps solution.

 

To call an existing assembly, please follow these steps:

  • Copy your assembly into the bin\Debug\net472\bin folder in your Functions project
  • Open up your .csproj file from your Functions project and add either an Absolute or Relative path to your assembly.KentWeareMSFT_1-1687300579822.png

 

  • Add a using statement at the top of your .cs file

KentWeareMSFT_0-1687301556685.png

 

  • Call your assembly from appropriate method

KentWeareMSFT_1-1687301741217.png

 

  • We now need to build the custom code project by issuing dotnet build using Terminal in the Functions project. After we build our project, we should notice that our existing assembly has been copied from our Functions project to our workflow project. Our custom assembly, and its dependencies, has also been copied into the lib\custom\net472 folder in our workflow project.KentWeareMSFT_2-1687302162610.png

 

  • With our build successfully completed, we can now configure our action to call function code that we just built.KentWeareMSFT_3-1687302793073.png

     

Conclusion

In this post, we brought in an existing assembly and plugged it into our solution. We discovered that the build tasks that are pre-configured for us in our Functions code project and will take care of bin-placing all assemblies in the correct location within our workflow project. This simplifies the local development of working with workflows and custom code.

 

Video Content

If you would like to see a video version of this content, please check out the following YouTube video.

Co-Authors
Version history
Last update:
‎Jun 26 2023 06:56 AM
Updated by: