This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
In this tutorial, you learn how to use a namespace topic to route data from MQTT clients to Azure Event Hubs.
Anamespace in Azure Event Grid is a logical container for one or more topics, clients, client groups, topic spaces, and permission bindings. With an Azure Event Grid namespace, you can group together related resources and manage them as a single unit in your Azure subscription. A unique namespace allows you to have multiple resources in the same Azure region.
To create a namespace:
Sign in to theAzure portal.
In the search box, enterEvent Grid Namespaces and selectEvent Grid Namespaces from the results.

On theEvent Grid Namespaces page, select+ Create.

On theBasics page, follow these steps.
Select the Azure subscription in which to create the namespace.
Select an existingResource group or create a resource group.
Enter aName for the namespace.
Select theLocation for the namespace.
SelectReview + create.

On theReview + create tab, review your settings. Then selectCreate.
On theDeployment succeeded page, selectGo to resource to navigate to your namespace.
If you aren't on the Event Grid Namespace page, follow thecreate, view, and manage namespaces steps to view the namespace you want to use to create the topic.
On theEvent Grid Namespace page, underEvent broker, selectTopics.
On theTopics page, select+ Topic.
On theCreate Topic page, type the name of the topic you want to create and selectCreate.

On theEvent Grid Namespace page, underSettings, selectIdentity.
To enable a system assigned managed identity, selectOn.
SelectSave to save the setting.
On the confirmation message, selectYes.
Confirm that you see the object ID of the system-assigned managed identity and see a link to assign roles.
Check notifications in the Azure portal to confirm that the managed identity is enabled for the namespace.
On theEvent Grid Namespace page, underSettings, selectConfiguration.
SelectEnable MQTT broker.
SelectApply.
Check notifications in the Azure portal to confirm that the MQTT broker is enabled for the namespace.
In a separate tab of the Web browser or in a separate window, use the Azure portal to create an Event Hubs namespace with an event hub.
An Event Hubs namespace provides a unique scoping container in which you create event hubs. To create a namespace in your resource group using the portal:
In the Azure portal, from the flyout menu, selectAll services. In theAll services page, search for and selectEvent Hubs.

In theEvent Hubs page, selectCreate.
On theCreate namespace page, take the following steps:
Select theSubscription in which you want to create the namespace.
Select theResource group you created in the previous step.
Enter a name for the namespace. The system immediately checks to see if the name is available.
Select aRegion for the namespace.
For the pricing tier, chooseBasic.
Note
If you plan to use the namespace fromApache Kafka apps, use theStandard tier. The basic tier doesn't support Apache Kafka workloads. To learn about differences between tiers, seeQuotas and limits,Event Hubs Premium, andEvent Hubs Dedicated articles.
Leave thethroughput units (for standard tier) orprocessing units (for premium tier) setting as it is. To learn about throughput units or processing units, seeEvent Hubs scalability.
SelectReview + Create.

On theReview + Create page, review the settings, and selectCreate. Wait for the deployment to complete.
On theDeployment page, selectGo to resource to navigate to the page for your namespace.

Confirm that you see theEvent Hubs Namespace page similar to the following example:
To create an event hub within the namespace, do the following actions:
On theOverview page, select+ Event Hub.

Type a name for your event hub, then selectReview + create.

On theReview + create page, selectCreate.
You can check the status of the event hub creation in alerts. After the event hub is created, you see it in the list of event hubs.

On theEvent Hubs Namespace page, selectAccess control (IAM).
On theAccess control page, select+ Add, and then selectAdd role assignment.

On theAdd role assignment page, from the list of roles, selectAzure Event Hubs Data Sender, and then selectNext.
On theMembers page, follow these steps:
For theAssign access to field, selectManaged identity.
Choose+ Select members.

On theSelect managed identities page, follow these steps:
Select your Azure subscription.
ForManaged identity, selectEvent Grid Namespace.
Select the managed identity that has the same name as the Event Grid namespace.
ChooseSelect.

On theAdd role assignment page, selectReview + assign.
On theReview + assign page, selectReview + assign.
Switch to the tab of your Web browser window that has the Event Grid namespace open.
On theEvent Grid Namespace page, selectTopics.
On theTopics page, select the namespace topic you created earlier.

On theEvent Grid Namespace Topic page, select+ Subscription.

On theCreate Subscription page, follow these steps:
Enter aName for the event subscription.
ForDelivery mode, selectPush.
Confirm thatEndpoint type is set toEvent Hub.
SelectConfigure an endpoint.

On theSelect Event Hub page, follow these steps:
Select the Azure subscription that has the event hub.
Select theResource Group that has the event hub.
Select theEvent Hubs Namespace.
Select theEvent Hub in the Event Hubs namespace.
Then, selectConfirm selection.

Back on theCreate Subscription page, selectSystem Assigned forManaged identity type.
SelectCreate.

Navigate back to theEvent Grid Namespace page by selecting the namespace in theEssentials section of theEvent Grid Namespace Topic page or by selecting the namespace name in the breadcrumb menu at the top.
On theEvent Grid Namespace page, underMQTT broker, selectRouting.
On theRouting page, selectEnable routing.
ForTopic type, selectNamespace topic.
ForTopic, select the Event Grid namespace topic that you created where all MQTT messages are routed.
SelectApply.

Check notifications to confirm that the namespace is enabled with the routing information.
Follow steps in this quickstart:Publish and subscribe on an MQTT topic to:
Create a client. You can create the second client if you want to, but it's optional.
Create a topic space.
Create publisher and subscriber permission bindings.
Use MQTTX to send a few messages.
Verify that the event hub received those messages on theOverview page for your Event Hubs namespace.
Navigate to the Event Hubs instance (event hub) in your event subscription in the Azure portal. Process data from your event hub by using Stream Analytics. For more information, seeProcess data from your event hub using Azure Stream Analytics. You can see the MQTT messages in the query.
For code samples, go to theMqttApplicationSamples GitHub repository.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?