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/event-grid/mqtt-routing-to-azure-functions-portal.md
+41-7Lines changed: 41 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,7 @@ ms.subservice: mqtt
10
10
11
11
# Tutorial: Route MQTT messages in Azure Event Grid to Azure Functions using custom topics - Azure portal
12
12
13
-
In this tutorial, you learn how to route MQTT messages received by an Azure Event Grid namespace to an Azure function via an Event Grid custom topic.
14
-
15
-
In this tutorial, you perform the following tasks:
13
+
In this tutorial, you learn how to route MQTT messages received by an Azure Event Grid namespace to an Azure function via an Event Grid custom topic by following these steps:
16
14
17
15
> [!div class="checklist"]
18
16
> * Create an Azure function using Event Grid trigger
@@ -26,15 +24,50 @@ If you don't have an Azure subscription, you can sign up for a [free trial](http
26
24
27
25
## Create an Azure function using Event Grid trigger
28
26
29
-
Follow instructions from [Create an Azure function using Visual Studio Code](../azure-functions/functions-develop-vs-code.md), but use the **Azure Event Grid Trigger** instead of using the **HTTP Trigger**.
27
+
Follow instructions from [Create an Azure function using Visual Studio Code](../azure-functions/functions-develop-vs-code.md), but use the **Azure Event Grid Trigger** instead of using the **HTTP Trigger**. You should see code similar to the following example:
You use this Azure function as an event handler for a topic's subscription later in this tutorial.
56
+
57
+
> [!NOTE]
58
+
> - Create all resources in the same region.
59
+
> - This tutorial has been tested with an Azure function that uses .NET 8.0 (isolated) runtime stack.
30
60
31
61
## Create an Event Grid topic (custom topic)
32
62
Create an Event Grid topic. See [Create a custom topic using the portal](/azure/event-grid/custom-event-quickstart-portal). When you create the Event Grid topic, on the **Advanced** tab, for **Event Schema**, select **Cloud Event Schema v1.0**.
33
63
34
64
:::image type="content" source="./media/mqtt-routing-to-azure-functions-portal/create-topic-cloud-event-schema.png" alt-text="Screenshot that shows the Advanced page of the Create Topic wizard.":::
35
65
66
+
> [!NOTE]
67
+
> Use **Cloud event schema** everywhere in this tutorial.
36
68
37
69
## Add a subscription to the topic using the function
70
+
In this step, you create a subscription to the Event Grid topic using the Azure function you created earlier.
38
71
39
72
1. On the Event Grid topic page, select **Subscriptions** on the left navigation bar.
40
73
@@ -62,15 +95,15 @@ Create an Event Grid topic. See [Create a custom topic using the portal](/azure/
62
95
63
96
Follow instructions from [Quickstart: Publish and subscribe to MQTT messages using an Event Grid namespace with Azure portal](mqtt-publish-and-subscribe-portal.md) to:
64
97
65
-
1. Create an Event Grid namespace.1.
98
+
1. Create an Event Grid namespace.
66
99
1. Create two clients.
67
100
1. Create a topic space.
68
101
1. Create publisher and subscriber permission bindings.
69
102
1. Test using [MQTTX app](https://mqttx.app/) to confirm that clients are able to send and receive messages.
70
103
71
104
## Enable managed identity for the namespace
72
105
73
-
In this section, you enable system-assigned managed identity for the Event Grid namespace, and then give the identity **send**access to the Event Grid custom topic you created earlier. You add the managed identity to the **Event Grid Data Sender** role on the custom topic.
106
+
In this section, you enable system-assigned managed identity for the Event Grid namespace. Then, grant identity the **send**permission to the Event Grid custom topic you created earlier so that it can route message to the custom topic. You do so by adding the managed identity to the **Event Grid Data Sender** role on the custom topic.
74
107
75
108
1. On the **Event Grid Namespace** page, select **Identity** on the left navigation menu.
76
109
@@ -97,6 +130,7 @@ In this section, you enable system-assigned managed identity for the Event Grid
97
130
1. On the **Review + assign** page, review settings, and then select **Review + assign** at the bottom of the page.
98
131
99
132
## Configure routing messages to Azure function via custom topic
133
+
In this step, you configure routing for the Event Grid namespace so that the messages it receives are routed to the custom topic you created.
100
134
101
135
1. On the **Event Grid Namespace** page, select **Routing** on the left navigation bar.
102
136
1. On the **Routing** page, select **Enable routing**.
@@ -110,7 +144,7 @@ In this section, you enable system-assigned managed identity for the Event Grid
110
144
## Send test MQTT messages using MQTTX
111
145
Send test MQTT messages to the namespace and confirm that the function receives them.
112
146
113
-
Follow instructions in the [Publish, subscribe messages using MQTTX app](mqtt-publish-and-subscribe-portal.md#publishsubscribe-using-mqttx-app)section to send a few test messages to the Event Grid namespace.
147
+
Follow instructions from the [Publish, subscribe messages using MQTTX app](mqtt-publish-and-subscribe-portal.md#publishsubscribe-using-mqttx-app)article to send a few test messages to the Event Grid namespace.
0 commit comments