Announcement: Introducing .NET Framework Custom Code for Azure Logic Apps (Standard) - Preview
Published Jun 22 2023 10:14 AM 11.5K Views
Microsoft

We are pleased to announce the public preview of .NET Framework Custom Code for Azure Logic Apps (Standard). This capability allows you to call compiled .NET Framework code from a built-in action in your workflow. In addition, this new capability provides the following benefits:

  • A no-cliffs extensibility capability to our low code offering giving developers the flexibility and control needed to solve the toughest integration problems.
  • No additional service plans required, deploy your custom code alongside your workflows.
  • A local debug experience, in VS Code, which allows you to step through your workflows and code in the same debugging session.
  • Supports BizTalk migration scenarios by allowing customers to lift and shift their custom .NET Framework investments from on-premises to the cloud.

Prerequisites

To use this feature, you will need a working instance of VS Code with all the existing Logic Apps (Standard) prerequisites.

In addition to the requirements already outlined, the following requirements must be satisfied:

  1. Microsoft Windows operating system
  2. We will support calling .NET Framework 4.7.2 assemblies. Please recompile assemblies as necessary to meet this requirement.

Create new logic app workspace

To support a streamlined experience of writing custom code and being able to debug and deploy it with your workflows, we are introducing a new logic app workspace template. This new template is available in the latest Logic Apps extension for VS Code. As part of this project template, we will be creating a workspace file and two sample projects. One of the projects will allow you to author custom code and the other project will be for authoring workflows.

 

Note: You cannot mix custom code and workflows in the same project.

 

You can create a new logic app workspace using the following steps:

  • Click on the Azure A in the left navigation followed by clicking on the icon.

1-CreateWorkspace.png

  • Select a folder for your project
  • You will now be prompted for some values including:
    1. Workspace name
    2. Function name for your code project
    3. A Namespace for your custom code
    4. Workflow template for your first workflow (Stateful or Stateless)
    5. A name for a workflow
  • Once you have completed those prompts you should see the following folder/file structure:

2-ProjectStructure.png

 

Authoring custom code

Within the Functions project, we will find a .cs file that contains the function that we created in the previous step. This function will include a default Run method that you can use to get started.  This sample method demonstrates some of the capabilities found in calling in our custom code feature including passing different inputs and outputs including complex .NET types.

 

Note: You can modify the existing Run method to meet your needs, or you can copy and paste the function, including the [FunctionName(“function-name”)] declaration, and rename it to ensure there is a unique name associated with it. Modify this new function as you see fit. You will also need to ensure you don't have 2 "Run" methods. Rename one of them so that you have unique method names.

 

3-codeFile.png

 

Building custom code

Once you have completed authoring your code, we need to compile it. As part of the project template that was used to create your Function project, we have included build tasks that will compile your code and then bin place it into the lib/custom/net472 folder within your Logic App project. This folder is where workflows will look for custom code.

To build your code:

  • Click on Terminal – New Terminal

KentWeareMSFT_0-1686764667353.png

  • Select Functions

KentWeareMSFT_2-1686764711628.png

  • Within the command prompt, type in dotnet restore and hit enter.
  • Type dotnet build and hit enter. 
    • Alternatively, you can also use the Run Build Task from the Terminal menu.
  • Verify in your Logic Apps project that you have dll files placed within lib\custom\net472 folder. Also look for a sub folder with the same name as the Function name that you provided when provisioning template. Within this folder you should see a file called function.json that contains metadata about the function code that you just wrote. The logic apps designer will use this file to determine the necessary inputs/outputs when calling custom code.

KentWeareMSFT_0-1686765217993.png

 

Configuring custom code from Logic Apps workflow

With our custom code now compiled and bin placed, we are ready to call it from a workflow. Within the LogicApp project we will have a sample workflow that we can use to call this custom code that we just built. To call this custom code, perform the following steps:

  • Right mouse click on the workflow.json file that was provisioned during provisioning step and select Open Designer.

KentWeareMSFT_2-1686765269799.png

 

  • The designer will launch and you will see a workflow presented that includes a Call a local function in this logic app action. Click on the action and you will see additional parameters populated.

KentWeareMSFT_0-1686767014835.png

 

  • You can explore this inputs by selecting Function Name  dropdown, changing the default ZipCode or changing the TemperatureScale from Celsius to Fahrenheit.
  • With your action configured, we can now run our workflow and call our custom code.

Debugging workflow and custom code

We are now ready to run and debug our solution. We can do so by performing the following steps:

  • We need to start Azurite 3 times for:
    • Azure Table Service
    • Azure Queue Service
    • Azure Blob Service
  • We can start Azurite by clicking on View – Command Palette

KentWeareMSFT_4-1686765321051.png

  • Type/find Azurite: Start
  • When prompted, select LogicApp

KentWeareMSFT_5-1686765339715.png

  • You will know you have done this correctly when you see the 3 services running near your taskbar at the bottom of the screen.

KentWeareMSFT_6-1686765359577.png

 

  • Let’s now attach our debugger to our Logic App project by clicking on Debug icon. Ensure that Attach to logic app (LogicApp) is selected and then click on green Play button.

KentWeareMSFT_7-1686765380936.png

  • It may take a minute for the Logic Apps debugger to launch, but you will know it has launched when you see 3 Functions launched.

KentWeareMSFT_9-1686765412588.png

 

Note: Depending upon the names that you provided during the provisioning step, you may have different values than above.

 

  • We now want to launch the .NET Functions debugger. We can do so by clicking on Debug icon, selecting Attach to .NET Functions and then click green Play button.

KentWeareMSFT_10-1686765444004.png

  • The taskbar should subsequently turn orange, indicating that the .NET debugger has been loaded.

KentWeareMSFT_11-1686765468799.png

 

  • Set breakpoints in your code and/or workflow config by click next to the line number in the appropriate code file. When you do so, you will see a red circle. You can do this in your workflow.json or .cs file.

KentWeareMSFT_12-1686765491165.png

 

  • We now need to reach the Overview page by right mouse clicking on our workflow.json file and then selecting Overview.

KentWeareMSFT_13-1686765511392.png

  • When the Overview page loads you should see a Callback URL  populated and a Run trigger button enabled. Click on the Run trigger button.

KentWeareMSFT_0-1686767808188.png

 

  • You should now see your first breakpoint is activated. Use the VS Code commands to continue (F5), Step Into (F11) or Step Out (Shift + F11).

KentWeareMSFT_14-1686765533392.png

 

  • Once your execution has completed, you should see a completed run in the Overview page. Explore as necessary.

KentWeareMSFT_15-1686765557985.png

 

Deploying custom code

You can deploy custom code in the same manner as you deploy your workflow project. So whether that is through VS Code or through a CI/CD DevOps process, you just need to ensure that you build your custom code before deployment and ensure that all dependent dlls are in the workflow’s lib/custom/net472 folder prior to deployment.

 

Azure Portal Support

We currently do not support the authoring of custom code in the Azure Portal, however for custom code that has been deployed, you can add the workflow action and configure different functions, inputs and outputs like any other Logic Apps workflow. You will also be able to access the run history and see inputs/outputs for this action.

 

Custom code usage guidelines

Customers are encouraged to use .NET Framework custom code extensibility to complement their low code integration solutions that they build in Azure Logic Apps. In general, custom code extensibility can be used to:

  1. Implement custom business logic
  2. Custom parsing
  3. Data validation
  4. Message shaping
  5. Calculations
  6. Simple data transformations

Conversely, .NET Framework custom code extensibility is not a substitute for:

  1. BizTalk pipeline components that implement streaming
  2. Complex batching/debatching scenarios
  3. Code processes that exceed more than 10 minutes in duration.
  4. Large message data transformations.

Please refer to the Azure Logic Apps limits and configuration reference for additional details.

 

Support for other languages?

We have priortized C# and .NET Framework support to help address BizTalk Migration needs. We also recognize that there may be needs for other languages. Since our existing solution is built upon Azure Functions, we do have opportunities to include additional languages that Azure Functions supports. Please add any additional languages that you would like to see support for in the comments.

 

Video Demo

If you would like to see a video demonstration of this content, please watch the following YouTube video.

 

29 Comments
Version history
Last update:
‎Jun 22 2023 09:48 AM
Updated by: