Announcement: Introducing .NET 8 Custom Code support for Azure Logic Apps (Standard) - Preview

  • Thread starter Thread starter Shree_Divya_M_V
  • Start date Start date
S

Shree_Divya_M_V

Introduction​




The support for .NET Framework custom code in Logic App Standard has been helping customer to call compiled custom code from the built-in action, offering the flexibility and control needed to solve tough integration problems.

We are excited to announce that this feature has been extended to support .NET 8 based workloads as well. This means that you can now use the latest version of .NET to write your custom code logic and invoke it from a logic app action.

This document will show you how to use custom code support for Azure Logic Apps Standard with .NET 8.



Prerequisites​




  • An Azure subscription. If you don't have one, you can create a free account here.
  • Azure Logic Apps (Standard) extension for Visual Studio Code. You can install it from the Visual Studio Marketplace.



Using .NET 8 based custom code in logic app​




Authoring, building, debugging and deploying experience are similar to the .NET framework based custom code project except that you choose the target framework as .NET 8 during the workspace creation.



More details on the .NET framework custom code support can be found in this blog- .NET Framework Custom Code for Azure Logic Apps (microsoft.com)



Create a Logic app workspace:​




A logic app workspace template creates 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.



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 Logic Apps icon and choose to Create a new logic app workspace

large?v=v2&px=999.png





  • Select a folder for your project and choose a Workspace name.
  • Choose “Logic app with custom code project” as a project template.

large?v=v2&px=999.png



  • Choose the target Framework as “.NET 8

large?v=v2&px=999.png



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

large?v=v2&px=999.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 two "Run" methods. Rename one of them so that you have unique method names.



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/net8 folder within your Logic App project. This folder is where workflows will look for custom code.

To build your code:

  1. Click on Terminal – New Terminal

large?v=v2&px=999.png



  1. Select Functions

large?v=v2&px=999.png



  1. Within the command prompt, type in dotnet restore and hit enter.
  2. Type dotnet build and hit enter.
    1. Alternatively, you can also use the Run Build Task from the Terminal menu.
  3. Verify in your Logic Apps project that you have dll files placed within lib\custom\net8 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.

Invoking the custom code from logic App workflow

  1. Right mouse click on the workflow.json file that was provisioned during provisioning step and select Open Designer.
  2. 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.
  3. You can explore these inputs by selecting Function Name dropdown, changing the default ZipCode or changing the TemperatureScale from Celsius to Fahrenheit.

large?v=v2&px=999.png



Debugging custom code with workflow​




  1. Start Azurite for Table, Queue and blob services by running below commands on the View –> Command Palette, when prompted select Logic App project folder

medium?v=v2&px=400.png



  1. Attach the debugger to Logic App project by clicking on Debug icon. Ensure that Attach to logic app (LogicApp) is selected and then click on green Play button.

large?v=v2&px=999.png



  1. To attach the debugger to .NET function project,
    1. From the command palette, choose Debug: Attach to a .NET 5+ or .NET Core process

large?v=v2&px=999.png



  1. Choose the dotnet.exe process. If there are multiple dotnet.exe processes, choose the one which has the below path. <Drive>:\Users\<user>\.azure-functions-core-tools\Functions\ExtensionBundles\Microsoft.Azure.Functions.ExtensionBundle.Workflows\<ExtensionBundleVersion>\CustomCodeNetFxWorker\net8\Microsoft.Azure.Workflows.Functions.CustomCodeNetFxWorker.dll

large?v=v2&px=999.png



  1. Set breakpoints in your code(.cs) and/or workflow(.json) by click next to the line number in the appropriate code file.
  2. Right click on the workflow.json file and select Overview.
  3. When the Overview page loads you should see a Callback URL populated and a Run trigger button enabled. Click on the Run trigger button.
  4. 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).

Deploying custom code​




You can deploy custom code in the same manner as you deploy your workflow project. Please ensure that you build your custom code before deployment and that all dependent dlls are in the workflow’s lib/custom/net8 folder prior to deployment.



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.

Continue reading...
 
Back
Top