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/logic-apps-scenario-function-sb-trigger.md
+29-20Lines changed: 29 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,49 +7,50 @@ ms.reviewer: estfan, azla
7
7
ms.topic: how-to
8
8
ms.date: 11/08/2019
9
9
ms.custom: devx-track-csharp
10
+
#Customer intent: As a logic apps developer, I want to use Azure Logic Apps to respond automatically and instantaneously to Azure Service Bus messages so that I don't have to monitor the messages manually.
10
11
---
11
12
12
13
# Call or trigger logic apps by using Azure Functions and Azure Service Bus
You can use [Azure Functions](../azure-functions/functions-overview.md) to trigger a logic app when you need to deploy a long-running listener or task. For example, you can create a function that listens in on an [Azure Service Bus](../service-bus-messaging/service-bus-messaging-overview.md) queue and immediately fires a logic app as a push trigger.
17
+
You can use [Azure Functions](../azure-functions/functions-overview.md) to trigger a logic app workflow when you need to deploy a long-running listener or task. For example, you can create a function that listens in on an [Azure Service Bus](../service-bus-messaging/service-bus-messaging-overview.md) queue and immediately fires a logic app as a push trigger.
17
18
18
19
## Prerequisites
19
20
20
-
* An Azure subscription. If you don't have an Azure subscription, [sign up for a free Azure account](https://azure.microsoft.com/free/).
21
+
* An Azure account and subscription. If you don't have a subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
21
22
22
23
* An Azure Service Bus namespace. If you don't have a namespace, [create your namespace first](../service-bus-messaging/service-bus-create-namespace-portal.md).
23
24
24
25
* A function app, which is a container for your functions. If you don't have a function app, [create your function app first](../azure-functions/functions-get-started.md), and make sure that you select .NET as the runtime stack.
25
26
26
-
* Basic knowledge about [how to create logic apps](../logic-apps/quickstart-create-first-logic-app-workflow.md)
27
+
* Basic knowledge about [how to create a Consumption logic app workflow](quickstart-create-first-logic-app-workflow.md) or [how to create a Standard logic app workflow](create-single-tenant-workflows-azure-portal.md).
27
28
28
-
## Create logic app
29
+
## Create a logic app workflow
29
30
30
-
For this scenario, you have a function running each logic app that you want to trigger. First, create a logic app that starts with an HTTP request trigger. The function calls that endpoint whenever a queue message is received.
31
+
For this scenario, you have a function running for each logic app that you want to trigger. First, create a logic app workflow that starts with an HTTP request trigger. The function calls that endpoint whenever a queue message is received.
31
32
32
33
1. Sign in to the [Azure portal](https://portal.azure.com), and create blank logic app.
33
34
34
35
If you're new to logic apps, review [Quickstart: Create your first logic app](../logic-apps/quickstart-create-first-logic-app-workflow.md).
35
36
36
37
1. In the search box, enter `http request`. From the triggers list, select the **When a HTTP request is received** trigger.
:::image type="content" source="./media/logic-apps-scenario-function-sb-trigger/when-http-request-received-trigger.png" alt-text="Screenshot of the designer in the portal. The search box contains 'http request.' Under 'Triggers,' 'When a HTTP request is received' is highlighted.":::
39
40
40
41
With the Request trigger, you can optionally enter a JSON schema to use with the queue message. JSON schemas help the Logic App Designer understand the structure for the input data, and make the outputs easier for you to use in your workflow.
41
42
42
43
1. To specify a schema, enter the schema in the **Request Body JSON Schema** box, for example:
:::image type="content" source="./media/logic-apps-scenario-function-sb-trigger/when-http-request-received-trigger-schema.png" alt-text="Screenshot of the details of an HTTP request trigger. Some JSON code is visible in the 'Request Body JSON Schema' box.":::
45
46
46
47
If you don't have a schema, but you have a sample payload in JSON format, you can generate a schema from that payload.
47
48
48
49
1. In the Request trigger, select **Use sample payload to generate schema**.
49
50
50
51
1. Under **Enter or paste a sample JSON payload**, enter your sample payload, and then select **Done**.
:::image type="content" source="./media/logic-apps-scenario-function-sb-trigger/enter-sample-payload.png" alt-text="Screenshot of the details of an HTTP request trigger. Under 'Enter or paste a sample JSON payload,' some payload data is visible.":::
53
54
54
55
This sample payload generates this schema that appears in the trigger:
55
56
@@ -89,7 +90,7 @@ For this scenario, you have a function running each logic app that you want to t
89
90
90
91
The callback URL appears in the **HTTP POST URL** property.
91
92
92
-

93
+
:::image type="content" source="./media/logic-apps-scenario-function-sb-trigger/callback-URL-for-trigger.png" alt-text="Screenshot of the details of an HTTP request trigger. Next to 'HTTP POST URL,' a URL is visible.":::
93
94
94
95
## Create a function
95
96
@@ -99,17 +100,11 @@ Next, create the function that acts as the trigger and listens to the queue.
99
100
100
101
1. Under your function app name, expand **Functions**. On the **Functions** pane, select **New function**.
101
102
102
-

103
+
:::image type="content" source="./media/logic-apps-scenario-function-sb-trigger/add-new-function-to-function-app.png" alt-text="Screenshot of the 'Functions' page of a function app in the portal, with 'Create' highlighted. On the navigation menu, 'Functions' is highlighted.":::
103
104
104
-
1. Select this template based on whether you created a new function app where you selected .NET as the runtime stack, or you're using an existing function app.
105
+
1. Select the **Azure Service Bus Queue trigger** template.
105
106
106
-
* For new function apps, select this template: **Service Bus Queue trigger**
107
-
108
-

109
-
110
-
* For an existing function app, select this template: **Service Bus Queue trigger - C#**
111
-
112
-

107
+
:::image type="content" source="./media/logic-apps-scenario-function-sb-trigger/current-add-queue-trigger-template.png" alt-text="Screenshot of the 'Create function' page of a function app in the portal. Under 'Template,' 'Azure Service Bus Queue trigger' is highlighted.":::
113
108
114
109
1. Under **Template details**, enter a name for your function, and set up the **Service Bus connection** for the queue, which uses the Azure Service Bus SDK `OnMessageReceive()` listener. Next, enter the queue name, and then select **Create**.
115
110
@@ -142,9 +137,23 @@ Next, create the function that acts as the trigger and listens to the queue.
142
137
}
143
138
```
144
139
145
-
1. To test the function, add a queue message by using a tool such as the [Service Bus Explorer](https://github.com/paolosalvatori/ServiceBusExplorer).
140
+
## Test your logic app workflow
141
+
142
+
1. To test your logic app workflow, use a tool to add a message to your Service Bus queue.
143
+
144
+
1. In the Azure portal, open your Service Bus namespace.
145
+
146
+
1. On the Service Bus namespace navigation menu, select **Queues**.
147
+
148
+
:::image type="content" source="./media/logic-apps-scenario-function-sb-trigger/service-bus-namespace-queues.png" alt-text="Screenshot of a Service Bus namespace in the Azure portal. On the navigation menu, 'Queues' is highlighted.":::
149
+
150
+
1. Select the queue that you linked to your function through its Service Bus connection.
151
+
152
+
1. On the queue navigation menu, select **Service Bus Explorer**, and then select **Send messages**.
153
+
154
+
:::image type="content" source="./media/logic-apps-scenario-function-sb-trigger/select-service-bus-explorer.png" alt-text="Screenshot of a Service Bus queue page in the portal, with 'Send message' highlighted. On the navigation menu, 'Service Bus Explorer' is highlighted.":::
146
155
147
-
The logic app triggers immediately after the function receives the message.
156
+
1. Use the tool to send a message to your Service Bus queue. The message triggers your logic app.
0 commit comments