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.
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:
Microsoft Windows operating system
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.
Select a folder for your project
You will now be prompted for some values including:
Function name for your code project
A Namespace for your custom code
Workflow template for your first workflow (Stateful or Stateless)
A name for a workflow
Once you have completed those prompts you should see the following folder/file structure:
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.
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
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.
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.
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.
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
Type/find Azurite: Start
When prompted, select LogicApp
You will know you have done this correctly when you see the 3 services running near your taskbar at the bottom of the screen.
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.
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.
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.
The taskbar should subsequently turn orange, indicating that the .NET debugger has been loaded.
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.
We now need to reach the Overview page by right mouse clicking on our workflow.json file and then selecting Overview.
When the Overview page loads you should see a Callback URL populated and a Run trigger button enabled. Click on the Run trigger button.
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).
Once your execution has completed, you should see a completed run in the Overview page. Explore as necessary.
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:
Implement custom business logic
Simple data transformations
Conversely, .NET Framework custom code extensibility is not a substitute for:
BizTalk pipeline components that implement streaming
Complex batching/debatching scenarios
Code processes that exceed more than 10 minutes in duration.
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.
If you would like to see a video demonstration of this content, please watch the following YouTube video.