Notes on consumer groups and not running the event monitor at the same time

pull/123/head
Jim Bennett 4 years ago
parent 32c600d510
commit 4baa575344

@ -384,6 +384,8 @@ For now, you won't be updating your server code. Instead you can use the Azure C
The time values in the annotations are in [UNIX time](https://wikipedia.org/wiki/Unix_time), representing the number of seconds since midnight on 1<sup>st</sup> January 1970. The time values in the annotations are in [UNIX time](https://wikipedia.org/wiki/Unix_time), representing the number of seconds since midnight on 1<sup>st</sup> January 1970.
Exit the event monitor when you are done.
### Task - control your IoT device ### Task - control your IoT device
You can also use the Azure CLI to call direct methods on your IoT device. You can also use the Azure CLI to call direct methods on your IoT device.

@ -311,7 +311,7 @@ This will create a folder inside the `soil-moisture-trigger` folder called `iot-
* `"type": "eventHubTrigger"` - this tells the function it needs to listen to events from an Event Hub * `"type": "eventHubTrigger"` - this tells the function it needs to listen to events from an Event Hub
* `"name": "events"` - this is the parameter name to use for the Event Hub events. This matches the parameter name in the `main` function in the Python code. * `"name": "events"` - this is the parameter name to use for the Event Hub events. This matches the parameter name in the `main` function in the Python code.
* `"direction": "in",` - this is an input binding, the data from the event hub comes into the function * `"direction": "in"` - this is an input binding, the data from the event hub comes into the function
* `"connection": ""` - this defines the name of the setting to read the connection string from. When running locally, this will read this setting from the `local.settings.json` file. * `"connection": ""` - this defines the name of the setting to read the connection string from. When running locally, this will read this setting from the `local.settings.json` file.
> 💁 The connection string cannot be stored in the `function.json` file, it has to be read from the settings. This is to stop you accidentally exposing your connection string. > 💁 The connection string cannot be stored in the `function.json` file, it has to be read from the settings. This is to stop you accidentally exposing your connection string.
@ -326,6 +326,10 @@ This will create a folder inside the `soil-moisture-trigger` folder called `iot-
### Task - run the event trigger ### Task - run the event trigger
1. Make sure you are not running the IoT Hub event monitor. If this is running at the same time as the functions app, the functions app will not be able to connect and consume events.
> 💁 Multiple apps can connect to the IoT Hub endpoints using different *consumer groups*. These are covered in a later lesson.
1. To run the Functions app, run the following command from the VS Code terminal 1. To run the Functions app, run the following command from the VS Code terminal
```sh ```sh

@ -341,6 +341,9 @@ The data will be saved as a JSON blob with the following format:
[2021-05-21T01:31:14.351Z] Writing blob to gps-sensor/4b6089fe-ba8d-11eb-bc7b-1e00621e3648.json - {'device_id': 'gps-sensor', 'timestamp': '2021-05-21T00:57:53.878Z', 'gps': {'lat': 47.73092, 'lon': -122.26206}} [2021-05-21T01:31:14.351Z] Writing blob to gps-sensor/4b6089fe-ba8d-11eb-bc7b-1e00621e3648.json - {'device_id': 'gps-sensor', 'timestamp': '2021-05-21T00:57:53.878Z', 'gps': {'lat': 47.73092, 'lon': -122.26206}}
``` ```
> 💁 Make sure you are not running the IoT Hub event monitor at the same time.
> 💁 You can find this code in the [code/functions](code/functions) folder. > 💁 You can find this code in the [code/functions](code/functions) folder.
### Task - verify the uploaded blobs ### Task - verify the uploaded blobs

@ -324,6 +324,8 @@ When you create an IoT Hub, you get the `$Default` consumer group created by def
geofence gps-sensor geofence gps-sensor
``` ```
> 💁 When you ran the IoT Hub event monitor in an earlier lesson, it connected to the `$Default` consumer group. This was why you can't run the event monitor and an event trigger. If you want to run both, then you can use other consumer groups for all your function apps, and keep `$Default` for the event monitor.
### Task - create a new IoT Hub trigger ### Task - create a new IoT Hub trigger
1. Add a new IoT Hub event trigger to your `gps-trigger` function app that you created in an earlier lesson. Call this function `geofence-trigger`. 1. Add a new IoT Hub event trigger to your `gps-trigger` function app that you created in an earlier lesson. Call this function `geofence-trigger`.

Loading…
Cancel
Save