Hi @John Wong Yek Hon Greetings! Thank you for posting this question here.
am I able to route the D2C messages from IoT Hub to my Service Bus?
Yes, you can set up message routing on a public facing IoT Hub end point and send device telemetry to a Private Service Bus.
Here are the configurations needed to enable this routing.
- Set
Allow trusted Microsoft services to bypass this firewall?
to Yes on the Service Bus namespace. You can find this setting under the Settings --> Networking configurations. Please refer the below image for reference. - Enable System managed identity on the IoT Hub resource. This setting can be found under Security settings --> Identity. Refer the below image
- Add role assignment
Azure Service Bus Data Sender role
to this system managed identity under the Service Bas namespace through Access Control (IAM). SelectAzure Service Bus Data Sender
under the roles and click Next to choose Members. Select the option Assign Access to Managed Identity and look for the System Managed identity resources when you click Select Members. The System Managed Identity would be created with the same name as your IoT Hub. Refer the below image Assign the role permissions to this identity - Create an IoT Hub message routing custom end point on the IoT Hub and use System Managed Identity for Authentication type.
- You can set the routing query to
true
to route all events or set up a custom query per your need and set the data source to Device Telemetry Message.
Once the above configurations are done, you should be able to route the device telemetry to the private Service Bus end point without any issues. Here is a reference to the documentation Egress connectivity from IoT Hub to other Azure resources which provides this details.
Hope this helps! Please let us know if you have any additional questions or need further assistance.
If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.