-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Routing_Instructions.md and routing references #42
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,68 @@ | ||||||
# Routing Telemetry | ||||||
Event Grid allows you to route your MQTT messages to Azure services or webhooks for further processing. Accordingly, you can build end-to-end solutions by leveraging your IoT data for data analysis, storage, and visualizations, among other use cases. | ||||||
|
||||||
The routing configuration enables you to send all your messages from your clients to an [Event Grid custom topic](https://learn.microsoft.com/en-us/azure/event-grid/custom-topics), and configuring [Event Grid event subscriptions](https://learn.microsoft.com/en-us/azure/event-grid/subscribe-through-portal) to route the messages from that custom topic to the [supported event handlers](https://review.learn.microsoft.com/en-us/azure/event-grid/event-handlers). | ||||||
|
||||||
These instructions guide you to route your filtered MQTT messages from your Event Grid namespace to an [Azure Event Hubs](https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-about) for further processing. Consider a use case where you want to route the telemetry from only vehicle1. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
## Configure resources | ||||||
Configure these resources after the Event Grid namespace configuration to enable the routing flow. | ||||||
|
||||||
### Create an Event Hubs instance | ||||||
Use [these instructions](https://learn.microsoft.com/en-us/azure/event-hubs/event-hubs-quickstart-cli) to create an Event Hubs instance. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
### Configure the Event Grid topic | ||||||
- Configure your Event Grid Topic where your messages will be routed. The region of the topic needs to match the region of your namespace. | ||||||
```bash | ||||||
az eventgrid topic create | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
--name {EG custom topic name} \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some of these are defined in the create an event hub instance instructions - we should either use the same vars or if these are from az.env, include |
||||||
-l {region name} \ | ||||||
-g $rg \ | ||||||
--input-schema cloudeventschemav1_0 | ||||||
``` | ||||||
- Assign EventGrid Data Sender role on the Event Grid topic to your principal ID | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is my principal ID here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The output I get back from the previous command has it as null There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, I see there's a note on this further down - I'd put it at the top here |
||||||
```bash | ||||||
az role assignment create | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
--assignee "{Your Principal ID}" \ | ||||||
--role "EventGrid Data Sender" \ | ||||||
--scope "/subscriptions/$sub_id/resourcegroups/$rg/providers/Microsoft.EventGrid/topics/{EG Custom Topic Name}" | ||||||
``` | ||||||
> Note: | ||||||
> You can find your principal ID using the command: az ad signed-in-user show | ||||||
|
||||||
### Configure your Event Grid event subcription | ||||||
|
||||||
Create an Event Grid event subscription to route these messages from the Event Grid topic to your Event Hubs instance. The subscription uses the "Subject Begins With" filter that filters on the MQTT topic used in the MQTT messages. | ||||||
|
||||||
```bash | ||||||
az eventgrid event-subscription create --name contosoEventSubscription \ | ||||||
--source-resource-id "/subscriptions/$sub_id/resourceGroups/$rg/providers/Microsoft.EventGrid/topics/{Your Event Grid Topic Name}" \ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we save the event grid topic name so the customers don't have to keep copying and pasting these commands to put their topic name in? |
||||||
--endpoint-type eventhub \ | ||||||
--endpoint /subscriptions/$sub_id/resourceGroups/$rg/providers/Microsoft.EventHub/namespaces/{Event Hub Namespace Name}/eventhubs/{Event Hub Name} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
--event-delivery-schema cloudeventschemav1_0 \ | ||||||
--subject-begins-with vehicles/vehicle1 | ||||||
``` | ||||||
|
||||||
### Configure routing in the Event Grid Namespace | ||||||
Set the routing configuration on the Event Grid referring to the Event Grid topic. | ||||||
|
||||||
```bash | ||||||
az resource update --id $res_id --is-full-object --properties '{ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. which resource id should this be? I was assuming the one in my az.env, but I get this error:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After changing to the patch command, I'm still getting an error Not sure if this is because I had the wrong resource id or should have somehow linked the event hub steps to my event grid namespace |
||||||
"properties": { | ||||||
"isZoneRedundant": true, | ||||||
"topicsConfiguration": { | ||||||
"inputSchema": "CloudEventSchemaV1_0" | ||||||
}, | ||||||
"topicSpacesConfiguration": { | ||||||
"state": "Enabled" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"routeTopicResourceId": "/subscriptions/{Subscription ID}/resourceGroups/{Resource Group ID}/providers/Microsoft.EventGrid/topics/{EG Custom Topic Name}" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nevermind, I see this has to be typed out :( |
||||||
} | ||||||
}, | ||||||
"location": "eastus2euap" | ||||||
}' | ||||||
``` | ||||||
### View the routed MQTT messages in Azure Event Hubs | ||||||
After you run the samples to send the MQTT messages, follow these steps to view the routed MQTT messages in Azure Event Hubs using Azure Stream Analytics query | ||||||
- Navigate to the Event Hubs instance on the Azure portal. | ||||||
- Go to [**Process data**](https://learn.microsoft.com/en-us/azure/event-hubs/process-data-azure-stream-analytics) using Azure Stream Analytics. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
- Observe the routed MQTT messages based on the default query. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.