Skip to content

Commit ace96b5

Browse files
authored
Merge pull request #208195 from w-azure/winona-event-grid
Added images, filled in missing steps
2 parents 261c107 + 4261697 commit ace96b5

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed
22 KB
Loading

articles/event-grid/publish-iot-hub-events-to-logic-apps.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ms.custom: devx-track-azurecli
1414

1515
Azure Event Grid enables you to react to events in IoT Hub by triggering actions in your downstream business applications.
1616

17-
This article walks through a sample configuration that uses IoT Hub and Event Grid. At the end, you have an Azure logic app set up to send a notification email every time a device connects or disconnects to your IoT hub. Event Grid can be used to get timely notification about critical devices disconnecting. Metrics and Diagnostics can take several (i.e. 20 or more -- though we don't want to put a number on it) minutes to show up in logs/alerts. That might be unacceptable for critical infrastructure.
17+
This article walks through a sample configuration that uses IoT Hub and Event Grid. At the end, you have an Azure logic app set up to send a notification email every time a device connects or disconnects to your IoT hub. Event Grid can be used to get timely notification about critical devices disconnecting. Metrics and Diagnostics can take several minutes (such as 20 minutes or more) to show up in logs / alerts. Longer processing times might be unacceptable for critical infrastructure.
1818

1919
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
2020

@@ -32,7 +32,7 @@ You can quickly create a new IoT hub using the Azure Cloud Shell terminal in the
3232

3333
1. On the upper right of the page, select the Cloud Shell button.
3434

35-
![Cloud Shell button](./media/publish-iot-hub-events-to-logic-apps/portal-cloud-shell.png)
35+
:::image type="content" source="./media/publish-iot-hub-events-to-logic-apps/portal-cloud-shell.png" alt-text="Screenshot of how to open the Azure Cloud Shell from the Azure portal." lightbox="./media/publish-iot-hub-events-to-logic-apps/portal-cloud-shell.png":::
3636

3737
1. Run the following command to create a new resource group:
3838

@@ -46,11 +46,11 @@ You can quickly create a new IoT hub using the Azure Cloud Shell terminal in the
4646
az iot hub create --name {your iot hub name} --resource-group {your resource group name} --sku S1
4747
```
4848

49-
1. Minimize the Cloud Shell terminal. You will return to the shell later in the tutorial.
49+
1. Minimize the Cloud Shell terminal. You'll return to the shell later in the tutorial.
5050

5151
## Create a logic app
5252

53-
Next, create a logic app and add an HTTP event grid trigger that processes requests from IoT hub.
53+
Next, create a logic app and add an HTTP Event Grid trigger that processes requests from IoT hub.
5454

5555
### Create a logic app resource
5656

@@ -112,6 +112,9 @@ A trigger is a specific event that starts your logic app. For this tutorial, the
112112
"metadataVersion": "1"
113113
}]
114114
```
115+
116+
> [!IMPORTANT]
117+
> Be sure to paste the JSON snippet into the box provided by the **Use sample payload to generate schema** link and not directly into the **Request Body JSON Schema** box. The sample payload link provides a way to generate the JSON content based on the JSON snippet. The final JSON that ends up in the request body is different than the JSON snippet.
115118
116119
This event publishes when a device is connected to an IoT hub.
117120

@@ -122,11 +125,11 @@ A trigger is a specific event that starts your logic app. For this tutorial, the
122125

123126
Actions are any steps that occur after the trigger starts the logic app workflow. For this tutorial, the action is to send an email notification from your email provider.
124127

125-
1. Select **New step**. This opens a window to **Choose an action**.
128+
1. Select **New step**. A window appears, prompting you to **Choose an action**.
126129

127130
1. Search for **Outlook**.
128131

129-
1. Based on your email provider, find and select the matching connector. This tutorial uses **Outlook.com**. The steps for other email providers are similar.
132+
1. Based on your email provider, find and select the matching connector. This tutorial uses **Outlook.com**. The steps for other email providers are similar. Alternatively, use Office 365 Outlook to skip the sign-in step.
130133

131134
![Select email provider connector](./media/publish-iot-hub-events-to-logic-apps/outlook-step.png)
132135

@@ -138,7 +141,11 @@ Actions are any steps that occur after the trigger starts the logic app workflow
138141

139142
* **To**: Enter the email address to receive the notification emails. For this tutorial, use an email account that you can access for testing.
140143

141-
* **Subject**: Fill in the text for the subject. When you click on the Subject text box, you can select dynamic content to include. For example, this tutorial uses `IoT Hub alert: {eventType}`. If you can't see Dynamic content, select the **Add dynamic content** hyperlink -- this toggles it on and off.
144+
* **Subject**: Fill in the text for the subject. When you click on the Subject text box, you can select dynamic content to include. For example, this tutorial uses `IoT Hub alert: {eventType}`. If you can't see **Dynamic content**, select the **Add dynamic content** hyperlink to toggle the **Dynamic content** view on or off.
145+
146+
After selecting `eventType`, you'll see the email form output so far. Select the **Send and email (V2)** to edit the body of your email.
147+
148+
:::image type="content" source="./media/publish-iot-hub-events-to-logic-apps/send-email.png" alt-text="Screenshot of the condensed body output form." lightbox="./media/publish-iot-hub-events-to-logic-apps/send-email.png":::
142149

143150
* **Body**: Write the text for your email. Select JSON properties from the selector tool to include dynamic content based on event data. If you can't see the Dynamic content, select the **Add dynamic content** hyperlink under the **Body** text box. If it doesn't show you the fields you want, click *more* in the Dynamic content screen to include the fields from the previous action.
144151

@@ -150,7 +157,7 @@ Actions are any steps that occur after the trigger starts the logic app workflow
150157

151158
### Copy the HTTP URL
152159

153-
Before you leave the Logic Apps Designer, copy the URL that your logic apps is listening to for a trigger. You use this URL to configure Event Grid.
160+
Before you leave the Logic Apps Designer, copy the URL that your logic app is listening to for a trigger. You use this URL to configure Event Grid.
154161

155162
1. Expand the **When a HTTP request is received** trigger configuration box by clicking on it.
156163

@@ -164,7 +171,7 @@ Before you leave the Logic Apps Designer, copy the URL that your logic apps is l
164171

165172
In this section, you configure your IoT Hub to publish events as they occur.
166173

167-
1. In the Azure portal, navigate to your IoT hub. You can do this by selecting **Resource groups**, then select the resource group for this tutorial, and then select your IoT hub from the list of resources.
174+
1. In the Azure portal, navigate to your IoT hub. You can find your IoT hub by selecting **IoT Hub** from your Azure dashboard, then select your IoT hub instance from the list of resources.
168175

169176
1. Select **Events**.
170177

@@ -205,27 +212,27 @@ In this section, you configure your IoT Hub to publish events as they occur.
205212

206213
Test your logic app by quickly simulating a device connection using the Azure CLI.
207214

208-
1. Select the Cloud Shell button to re-open your terminal.
215+
1. Select the Cloud Shell button to reopen your terminal.
209216

210217
1. Run the following command to create a simulated device identity:
211218

212219
```azurecli
213220
az iot hub device-identity create --device-id simDevice --hub-name {YourIoTHubName}
214221
```
215222
216-
This could take a minute. You'll see a `json` printout once it's created.
223+
The processing could take a minute. You'll see a JSON printout in your console once it's created.
217224
218225
1. Run the following command to simulate connecting your device to IoT Hub and sending telemetry:
219226
220227
```azurecli
221228
az iot device simulate -d simDevice -n {YourIoTHubName}
222229
```
223230
224-
1. When the simulated device connects to IoT Hub, you will receive an email notifying you of a "DeviceConnected" event.
231+
1. When the simulated device connects to IoT Hub, you'll receive an email notifying you of a "DeviceConnected" event.
225232
226-
1. When the simulation completes, you will receive an email notifying you of a "DeviceDisconnected" event.
233+
1. When the simulation completes, you'll receive an email notifying you of a "DeviceDisconnected" event.
227234
228-
![Example alert mail](./media/publish-iot-hub-events-to-logic-apps/alert-mail.png)
235+
:::image type="content" source="./media/publish-iot-hub-events-to-logic-apps/alert-mail.png" alt-text="Screenshot of the email you should receive." lightbox="./media/publish-iot-hub-events-to-logic-apps/alert-mail.png":::
229236
230237
## Clean up resources
231238
@@ -235,7 +242,7 @@ To delete all of the resources created in this tutorial, delete the resource gro
235242
236243
1. Select **Resource groups**, then select the resource group you created for this tutorial.
237244
238-
2. On the Resource group pane, select **Delete resource group**. You are prompted to enter the resource group name, and then you can delete it. All of the resources contained therein are also removed.
245+
2. On the Resource group pane, select **Delete resource group**. You're prompted to enter the resource group name, and then you can delete it. All of the resources contained therein are also removed.
239246
240247
## Next steps
241248
@@ -246,4 +253,4 @@ To delete all of the resources created in this tutorial, delete the resource gro
246253
For a complete list of supported Logic App connectors, see the
247254
248255
> [!div class="nextstepaction"]
249-
> [Connectors overview](/connectors/).
256+
> [Connectors overview](/connectors/).

0 commit comments

Comments
 (0)