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/iot-hub/tutorial-routing-config-message-routing-CLI.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,18 +26,18 @@ If you want to view the finished script, download the [Azure IoT C# Samples](htt
26
26
27
27
## Use the Azure CLI to create your resources
28
28
29
+
Copy and paste the script below into Cloud Shell and press Enter. It runs the script one line at a time. This first section of the script will create the base resources for this tutorial, including the storage account, IoT Hub, Service Bus Namespace, and Service Bus queue. As you go through the rest of the tutorial, copy each block of script and paste it into Cloud Shell to run it.
30
+
31
+
> [!TIP]
32
+
> A tip about debugging: this script uses the continuation symbol (the backslash `\`) to make the script more readable. If you have a problem running the script, make sure your Cloud Shell session is running `bash` and that there are no spaces after any of the backslashes.
33
+
>
34
+
29
35
There are several resource names that must be globally unique, such as the IoT Hub name and the storage account name. To make this easier, those resource names are appended with a random alphanumeric value called *randomValue*. The randomValue is generated once at the top of the script and appended to the resource names as needed throughout the script. If you don't want it to be random, you can set it to an empty string or to a specific value.
30
36
31
37
> [!IMPORTANT]
32
38
> The variables set in the initial script are also used by the routing script, so run all of the script in the same Cloud Shell session. If you open a new session to run the script for setting up the routing, several of the variables will be missing values.
33
39
>
34
40
35
-
Copy and paste the script below into Cloud Shell and press Enter. It runs the script one line at a time. This first section of the script will create the base resources for this tutorial, including the storage account, IoT Hub, Service Bus Namespace, and Service Bus queue. As you go through the rest of the tutorial, copy each block of script and paste it into Cloud Shell to run it.
36
-
37
-
> [!TIP]
38
-
> A tip about debugging: this script uses the continuation symbol (the backslash `\`) to make the script more readable. If you have a problem running the script, make sure there are no spaces after any of the backslashes.
39
-
>
40
-
41
41
```azurecli-interactive
42
42
# This command retrieves the subscription id of the current Azure account.
43
43
# This field is used when setting up the routing queries.
@@ -151,7 +151,7 @@ To create a routing endpoint, use [az iot hub routing-endpoint create](/cli/azur
151
151
152
152
First, set up the endpoint for the storage account, then set up the route.
153
153
154
-
These variables are set:
154
+
These are the variables used by the script that must be set within your Cloud Shell session:
155
155
156
156
**storageConnectionString**: This value is retrieved from the storage account set up in the previous script. It is used by the message routing to access the storage account.
157
157
@@ -171,7 +171,7 @@ These variables are set:
171
171
172
172
**endpointName**: This field is the name identifying the endpoint.
173
173
174
-
**enabled**: This field defaults to `true`, indicating that the message route should be enabled after created.
174
+
**enabled**: This field defaults to `true`, indicating that the message route should be enabled after being created.
175
175
176
176
**condition**: This field is the query used to filter for the messages sent to this endpoint. The query condition for the messages being routed to storage is `level="storage"`.
echo "service bus queue connection string = " $sbqConnectionString
254
254
```
255
255
256
-
Now set up the routing endpoint and the message route for the Service Bus queue. These variables are set:
256
+
Now set up the routing endpoint and the message route for the Service Bus queue. These are the variables used by the script that must be set within your Cloud Shell session:
257
257
258
258
**endpointName**: This field is the name identifying the endpoint.
Copy file name to clipboardExpand all lines: articles/iot-hub/tutorial-routing-config-message-routing-PowerShell.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,14 +30,14 @@ Start by creating the resources with PowerShell.
30
30
31
31
### Use PowerShell to create your base resources
32
32
33
+
Copy and paste the script below into Cloud Shell and press Enter. It runs the script one line at a time. This first section of the script will create the base resources for this tutorial, including the storage account, IoT Hub, Service Bus Namespace, and Service Bus queue. As you go through the tutorial, copy each block of script and paste it into Cloud Shell to run it.
34
+
33
35
There are several resource names that must be globally unique, such as the IoT Hub name and the storage account name. To make this easier, those resource names are appended with a random alphanumeric value called *randomValue*. The randomValue is generated once at the top of the script and appended to the resource names as needed throughout the script. If you don't want it to be random, you can set it to an empty string or to a specific value.
34
36
35
37
> [!IMPORTANT]
36
38
> The variables set in the initial script are also used by the routing script, so run all of the script in the same Cloud Shell session. If you open a new session to run the script for setting up the routing, several of the variables will be missing values.
37
39
>
38
40
39
-
Copy and paste the script below into Cloud Shell and press Enter. It runs the script one line at a time. This first section of the script will create the base resources for this tutorial, including the storage account, IoT Hub, Service Bus Namespace, and Service Bus queue. As you go through the tutorial, copy each block of script and paste it into Cloud Shell to run it.
40
-
41
41
```azurepowershell-interactive
42
42
# This command retrieves the subscription id of the current Azure account.
43
43
# This field is used when setting up the routing queries.
@@ -136,7 +136,7 @@ First, set up the endpoint for the storage account, then create the message rout
These are the variables used by the script that must be set within your Cloud Shell session:
140
140
141
141
**resourceGroup**: There are two occurrences of this field -- set both of them to your resource group.
142
142
@@ -158,7 +158,7 @@ These variables are set:
158
158
159
159
**condition**: This field is the query used to filter for the messages sent to this endpoint. The query condition for the messages being routed to storage is `level="storage"`.
160
160
161
-
**enabled**: This field defaults to `true`, indicating that the message route should be enabled after created.
161
+
**enabled**: This field defaults to `true`, indicating that the message route should be enabled after being created.
162
162
163
163
Copy this script and paste it into your Cloud Shell window.
Now set up the routing endpoint and the message route for the Service Bus queue. These variables are set:
231
+
Now set up the routing endpoint and the message route for the Service Bus queue. These are the variables used by the script that must be set within your Cloud Shell session:
232
232
233
233
**endpointName**: This field is the name identifying the endpoint.
Copy file name to clipboardExpand all lines: articles/iot-hub/tutorial-routing-config-message-routing-RM-template.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -367,7 +367,7 @@ The files are uploaded to the share used by your Cloud Shell instance.
367
367
368
368
Run the script to perform the deployment. The last line of this script retrieves the variable that was set up to be returned -- the Service Bus queue connection string.
369
369
370
-
These variables are set in this script.
370
+
The script sets and uses these variables:
371
371
372
372
**$RGName** is the resource group name to which to deploy the template. This field is created before deploying the template.
Select **Create**. It may take a few minutes for the app to deploy.
51
51
52
-
2. Now go to the Logic App. The easiest way to get to the Logic App is to select **Resource groups**, select your resource group (this tutorial uses **ContosoResources**), then select the Logic App from the list of resources. The Logic Apps Designer page appears (you might have to scroll over to the right to see the full page). On the Logic Apps Designer page, scroll down until you see the tile that says **Blank Logic App +** and select it. The default tab is "For You". If this pane is blank, select **All** to see all of the connectors and triggers available.
52
+
2. Now go to the Logic App. The easiest way to get to the Logic App is to select **Resource groups**, select your resource group (this tutorial uses **ContosoResources**), then select the Logic App from the list of resources.
53
+
54
+
The Logic Apps Designer page appears (you might have to scroll over to the right to see the full page). On the Logic Apps Designer page, scroll down until you see the tile that says **Blank Logic App +** and select it. The default tab is "For You". If this pane is blank, select **All** to see all of the connectors and triggers available.
53
55
54
56
3. Select **Service Bus** from the list of connectors.
55
57
@@ -71,7 +73,7 @@ The Service Bus queue is to be used for receiving messages designated as critica
7. Now set up the action to send an e-mail when a message is received in the queue. In the Logic Apps Designer, select **+ New step** to add a step, then select **All** to see all of the options available. In the **Choose an action** pane, find and select **Office 365 Outlook**. On the triggers screen, select **Send an e-mail / Office 365 Outlook**.
76
+
7. Now set up the action to send an e-mail when a message is received in the queue. In the Logic Apps Designer, select **+ New step** to add a step, then select **All** to see all of the options available. In the **Choose an action** pane, find and select **Office 365 Outlook**. On the Actions screen, select **Send an e-mail / Office 365 Outlook**.
@@ -103,7 +105,9 @@ To see the data in a Power BI visualization, first set up a Stream Analytics job
103
105
104
106

105
107
106
-
3. Select **Create** to create the job. To get back to the job, select **Resource groups**. This tutorial uses **ContosoResources**. Select the resource group, then select the Stream Analytics job in the list of resources.
108
+
3. Select **Create** to create the job. It may take a few minutes to deploy.
109
+
110
+
To get back to the job, select **Resource groups**. This tutorial uses **ContosoResources**. Select the resource group, then select the Stream Analytics job in the list of resources.
107
111
108
112
### Add an input to the Stream Analytics job
109
113
@@ -117,13 +121,13 @@ To see the data in a Power BI visualization, first set up a Stream Analytics job
117
121
118
122
**Subscription**: Select the Azure subscription you're using for this tutorial.
119
123
120
-
**IoT Hub**: Select the IoT Hub. This tutorial uses **ContosoTestHub**.
124
+
**IoT Hub**: Select the IoT hub. This tutorial uses **ContosoTestHub**.
121
125
122
126
**Endpoint**: Select **Messaging**. (If you select Operations Monitoring, you get the telemetry data about the IoT hub rather than the data you're sending through.)
123
127
124
128
**Shared access policy name**: Select **service**. The portal fills in the Shared Access Policy Key for you.
125
129
126
-
**Consumer group**: Select the consumer group set up in step 1 of this tutorial. This tutorial uses **contosoconsumers**.
130
+
**Consumer group**: Select the consumer group set up in Part 1 of this tutorial. This tutorial uses **contosoconsumers**.
127
131
128
132
For the rest of the fields, accept the defaults.
129
133
@@ -173,20 +177,20 @@ To set up the Power BI report, you need data, so you'll set up Power BI after cr
173
177
174
178
## Run simulated device app
175
179
176
-
In the part 1 of this tutorial, you set up a device to simulate using an IoT device. In this section, you download the .NET console app that simulates that device sending device-to-cloud messages to an IoT hub, assuming you didn't already download the app and resources in part 1 of this tutorial.
180
+
In Part 1 of this tutorial, you set up a device to simulate using an IoT device. In this section, you download the .NET console app that simulates that device sending device-to-cloud messages to an IoT hub (assuming you didn't already download the app and resources in Part 1).
177
181
178
182
This application sends messages for each of the different message routing methods. There is also a folder in the download that contains the complete Azure Resource Manager template and parameters file, as well as the Azure CLI and PowerShell scripts.
179
183
180
-
If you didn't download the files from the repository in step 1 of this tutorial, go ahead and download them now from [IoT Device Simulation](https://github.com/Azure-Samples/azure-iot-samples-csharp/archive/master.zip). Selecting this link downloads a repository with several applications in it; the solution you are looking for is iot-hub/Tutorials/Routing/IoT_SimulatedDevice.sln.
184
+
If you didn't download the files from the repository in Part 1 of this tutorial, go ahead and download them now from [IoT Device Simulation](https://github.com/Azure-Samples/azure-iot-samples-csharp/archive/master.zip). Selecting this link downloads a repository with several applications in it; the solution you are looking for is iot-hub/Tutorials/Routing/IoT_SimulatedDevice.sln.
181
185
182
-
Double-click on the solution file (IoT_SimulatedDevice.sln) to open the code in Visual Studio, then open Program.cs. Substitute `{iot hub hostname}` with the IoT hub host name. The format of the IoT hub host name is **{iot-hub-name}.azure-devices.net**. For this tutorial, the hub host name is **ContosoTestHub.azure-devices.net**. Next, substitute `{device key}` with the device key you saved earlier when setting up the simulated device.
186
+
Double-click on the solution file (IoT_SimulatedDevice.sln) to open the code in Visual Studio, then open Program.cs. Substitute `{your hub name}` with the IoT hub host name. The format of the IoT hub host name is **{iot-hub-name}.azure-devices.net**. For this tutorial, the hub host name is **ContosoTestHub.azure-devices.net**. Next, substitute `{your device key}` with the device key you saved earlier when setting up the simulated device.
// This is the primary key for the device. This is in the portal.
188
192
// Find your IoT hub in the portal > IoT devices > select your device > copy the key.
189
-
staticstringdeviceKey="{your device key here}";
193
+
staticstrings_deviceKey="{your device key}";
190
194
```
191
195
192
196
## Run and test
@@ -207,15 +211,17 @@ If everything is set up correctly, at this point you should see the following re
207
211
* The Logic App retrieving the message from the Service Bus queue is working correctly.
208
212
* The Logic App connector to Outlook is working correctly.
209
213
210
-
2. In the [Azure portal](https://portal.azure.com), select **Resource groups** and select your Resource Group. This tutorial uses **ContosoResources**. Select the storage account, select **Blobs**, then select the Container. This tutorial uses **contosoresults**. You should see a folder, and you can drill down through the directories until you see one or more files. Open one of those files; they contain the entries routed to the storage account.
214
+
2. In the [Azure portal](https://portal.azure.com), select **Resource groups** and select your Resource Group. This tutorial uses **ContosoResources**.
215
+
216
+
Select the storage account, select **Containers**, then select the Container. This tutorial uses **contosoresults**. You should see a folder, and you can drill down through the directories until you see one or more files. Open one of those files; they contain the entries routed to the storage account.
211
217
212
218

213
219
214
220
This result means the following statement is true.
215
221
216
222
* The routing to the storage account is working correctly.
217
223
218
-
Now with the application still running, set up the Power BI visualization to see the messages coming through the default routing.
224
+
Now, with the application still running, set up the Power BI visualization to see the messages coming through the default routing.
219
225
220
226
## Set up the Power BI visualizations
221
227
@@ -245,11 +251,11 @@ Now with the application still running, set up the Power BI visualization to see
245
251
246
252
A line chart is created. The x-axis displays date and time in the UTC time zone. The y-axis displays temperature from the sensor.
247
253
248
-
6. Create another line chart to show real-time humidity over time. To set up the second chart, follow the same steps above and place **EventEnqueuedUtcTime** on the x-axis and **humidity** on the y-axis.
254
+
6. Create another line chart to show real-time humidity over time. To set up the second chart, follow the same process for the first chart, placing **EventEnqueuedUtcTime** on the x-axis (**Axis**) and **humidity** on the y-axis (**Values**).
249
255
250
256

251
257
252
-
7. Select **Save** to save the report.
258
+
7. Select **Save** to save the report, entering a name for the report if prompted.
253
259
254
260
You should be able to see data on both charts. This result means the following statements are true:
255
261
@@ -261,7 +267,7 @@ You can refresh the charts to see the most recent data by selecting the Refresh
261
267
262
268
## Clean up resources
263
269
264
-
If you want to remove all of the resources you've created through both parts of this tutorial, delete the resource group. This action deletes all resources contained within the group. In this case, it removes the IoT hub, the Service Bus namespace and queue, the Logic App, the storage account, and the resource group itself.
270
+
If you want to remove all of the Azure resources you've created through both parts of this tutorial, delete the resource group. This action deletes all resources contained within the group. In this case, it removes the IoT hub, the Service Bus namespace and queue, the Logic App, the storage account, and the resource group itself. You can also remove the Power BI resources and clear the emails sent during the tutorial.
265
271
266
272
### Clean up resources in the Power BI visualization
267
273
@@ -283,6 +289,10 @@ To remove the resource group, use the [Remove-AzResourceGroup](https://docs.micr
283
289
Remove-AzResourceGroup -Name $resourceGroup
284
290
```
285
291
292
+
### Clean up test emails
293
+
294
+
You may also want to delete the quantity of emails in your inbox that were generated through the Logic App while the device application was running.
295
+
286
296
## Next steps
287
297
288
298
In this 2-part tutorial, you learned how to use message routing to route IoT Hub messages to different destinations by performing the following tasks.
0 commit comments