You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/logic-apps/create-run-custom-code-functions.md
+10-44Lines changed: 10 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,8 +54,6 @@ For more information about limitations in Azure Logic Apps, see [Limits and conf
54
54
55
55
- Custom functions authoring currently isn't available in the Azure portal. However, after you deploy your functions from Visual Studio Code to Azure, follow the steps in [Call your code from a workflow](#call-code-from-workflow) for the Azure portal. You can use the built-in action named **Call a local function in this logic app** to select from your deployed custom functions and run your code. Subsequent actions in your workflow can reference the outputs from these functions, as in any other workflow. You can view the built-in action's run history, inputs, and outputs.
56
56
57
-
- Custom functions use an isolated worker to invoke the code in your logic app workflow. To avoid package references conflicts between your own function code and the worker, use the same package versions referenced by the worker. For the full package list and versions referenced by the worker, see [Worker and package dependencies](https://github.com/Azure/logicapps/blob/master/articles/worker-packages-dependencies-custom-code.pdf).
58
-
59
57
## Create a code project
60
58
61
59
The latest Azure Logic Apps (Standard) extension for Visual Studio Code includes a code project template that provides a streamlined experience for writing, debugging, and deploying your own code with your workflows. This project template creates a workspace file and two sample projects: one project to write your code, the other project to create your workflows.
@@ -102,8 +100,8 @@ The latest Azure Logic Apps (Standard) extension for Visual Studio Code includes
102
100
| Node | Description |
103
101
|------|-------------|
104
102
|**<*workspace-name*>**| Contains both your .NET functions project and logic app workflow project. |
105
-
|**Functions**| Contains the artifacts for your .NET functions project. For example, the **<*function-name*>.cs** file is the code file where you can author your code. |
106
-
|**LogicApp**| Contains the artifacts for your logic app project, including a blank workflow. |
103
+
|**<*function-name*>**| Contains the artifacts for your .NET functions project. For example, the **<*function-name*>.cs** file is the code file where you can author your code. |
104
+
|**<*logic-app-name*>**| Contains the artifacts for your logic app project, including a blank workflow. |
107
105
108
106
## Write your code
109
107
@@ -230,31 +228,19 @@ The latest Azure Logic Apps (Standard) extension for Visual Studio Code includes
230
228
}
231
229
```
232
230
233
-
1. Replace the sample function code with your own, and edit the default `Run` method for your own scenarios. Or, you can copy the function, including the `[FunctionName("<*function-name*>")]` declaration, and then rename the function with a unique name. You can then edit the renamed function to meet your needs.
231
+
1. Replace the sample function code with your own, and edit the default `Run` method for your own scenarios. Or, you can copy the function, including the `[FunctionName("<function-name>")]` declaration, and then rename the function with a unique name. You can then edit the renamed function to meet your needs.
234
232
235
233
This example continues with the sample code without any changes.
236
234
237
235
## Compile and build your code
238
236
239
237
After you finish writing your code, compile to make sure that no build errors exist. Your .NET functions project automatically includes build tasks, which compile and then add your code to the **lib\custom** folder in your logic app project where workflows look for custom functions to run. These tasks put the assemblies in the **lib\custom\net472** or **lib\custom\net8** folder, based on your .NET version.
240
238
241
-
1. In Visual Studio Code, from the **Terminal** menu, select **New Terminal**.
242
-
243
-
1. From the working directory list that appears, select **Functions** as your current working directory for the new terminal.
244
-
245
-
:::image type="content" source="media/create-run-custom-code-functions/compile-function-project.png" alt-text="Screenshot shows Visual Studio Code, prompt for current working directory, and selected Functions directory.":::
246
-
247
-
Visual Studio Code opens a terminal window with a command prompt.
248
-
249
-
1. In the **Terminal** window, at the command prompt, enter **dotnet restore**.
239
+
1. In the Visual Studio Code file explorer, right-click the functions project folder and select "Build functions project...".
250
240
251
-
Visual Studio Code analyzes your projects and determines whether they're up-to-date.
241
+
:::image type="content" source="media/create-run-custom-code-functions/build-functions-project.png" alt-text="Screenshot shows Visual Studio Code, Logic App workspace file explorer, and the Build functions project context menu option.":::
252
242
253
-
:::image type="content" source="media/create-run-custom-code-functions/dotnet-restore-complete.png" alt-text="Screenshot shows Visual Studio Code, Terminal window, and completed dotnet restore command.":::
254
-
255
-
1. After the command prompt reappears, enter **dotnet build**. Or, from the **Terminal** menu, select **Run Task**. From the task list, select **build (Functions)**.
256
-
257
-
If your build succeeds, the **Terminal** window reports that the **Build succeeded**.
243
+
1. The build task will execute for the functions project. If your build succeeds, the **Terminal** window reports that the **Build succeeded**.
258
244
259
245
1. Confirm that the following items exist in your logic app project:
260
246
@@ -290,7 +276,7 @@ After you confirm that your code compiles and that your logic app project contai
290
276
291
277
## Debug your code and workflow
292
278
293
-
1.Repeat the following steps to start the Azurite storage emulator *three* times: one time each for the following Azure Storage services:
279
+
1.Start the Azurite storage emulator for each of the Azure Storage services:
294
280
295
281
- Azure Blob Service
296
282
- Azure Queue Service
@@ -308,38 +294,18 @@ After you confirm that your code compiles and that your logic app project contai
308
294
309
295
:::image type="content" source="media/create-run-custom-code-functions/storage-services-running.png" alt-text="Screenshot shows Visual Studio Code taskbar with Azure Blob Service, Azure Queue Service, and Azure Table Service running.":::
310
296
311
-
1. Attach the debugger to your logic app project by following these steps:
297
+
1. Attach the debugger to your logic app project and .NET functions project by following these steps:
312
298
313
299
1. On the Visual Studio Code Activity Bar, select **Run and Debug**. (Keyboard: Ctrl+Shift+D)
314
300
315
301
:::image type="content" source="media/create-run-custom-code-functions/run-debug.png" alt-text="Screenshot shows Visual Studio Code Activity Bar with Run and Debug selected.":::
316
302
317
-
1. From the **Run and Debug** list, select **Attach to logic app (LogicApp)**, if not already selected, and then select **Play** (green arrow).
303
+
1. From the **Run and Debug** list, select **Run/debug logic app with local function (LogicApp)**, if not already selected, and then select **Play** (green arrow).
318
304
319
-
:::image type="content" source="media/create-run-custom-code-functions/attach-debugger-logic-app.png" alt-text="Screenshot shows Run and Debug list with Attach to logic app selected and Play button selected.":::
305
+
:::image type="content" source="media/create-run-custom-code-functions/attach-debugger-logic-app-with-local-function.png" alt-text="Screenshot shows Run and Debug list with Run/debug logic app with local function selected.":::
320
306
321
307
The **Terminal** window opens and shows the started debugging process. The **Debug Console** window then appears and shows the debugging statuses. At the bottom of Visual Studio Code, the task bar turns orange, indicating that the .NET debugger is loaded.
322
308
323
-
1. Attach the debugger to your .NET functions project by following these steps, based on your code:
324
-
325
-
**.NET 8 projects**
326
-
327
-
1. From the Visual Studio Code **View** menu, select **Command Palette**.
328
-
329
-
1. From the command palette, find and select **Debug: Attach to a .NET 5+ or .NET Core process**.
330
-
331
-
:::image type="content" source="media/create-run-custom-code-functions/attach-debugger-net-core.png" alt-text="Screenshot shows Run and Debug list with Attach to NET Functions selected and Play button selected.":::
332
-
333
-
1. From the list, find and select the **dotnet.exe** process. If multiple **dotnet.exe** processes exist, select the process that has the following path:
From the **Run and Debug** list, select **Attach to .NET Functions (Functions)**, if not already selected, and then select **Play** (green arrow).
340
-
341
-
:::image type="content" source="media/create-run-custom-code-functions/attach-debugger-net-functions.png" alt-text="Screenshot shows Run and Debug list with Attach to NET Functions (Functions) selected and Play button selected.":::
342
-
343
309
1. To set any breakpoints, in your function definition (**<*function-name*>.cs**) or workflow definition (**workflow.json**), find the line number where you want the breakpoint, and select the column to the left, for example:
344
310
345
311
:::image type="content" source="media/create-run-custom-code-functions/set-breakpoint.png" alt-text="Screenshot shows Visual Studio Code and the open function code file with a breakpoint set for a line in code.":::
0 commit comments