error in the sending data from azure iothub

gugulothu shiva 0 Reputation points
2026-08-20T04:50:52.68+00:00

we wanted to send data from azure iothub to anylogic. we are getting the authentication error. can anybody help to solve this errorimage (8)

Azure IoT SDK
Azure IoT SDK

An Azure software development kit that facilitates building applications that connect to Azure IoT services.

0 comments No comments

1 answer

Sort by: Newest
  1. Allan Solomon Mejia 9,735 Reputation points
    2026-08-20T18:30:40.74+00:00

    Hello @gugulothu shiva

    From the screenshot, the important part of the error is:

    AuthenticationError('CBS Token authentication failed...')

    This indicates that your Event Processor is reaching the IoT Hub built-in Event Hubs-compatible endpoint, but authentication to that endpoint is failing. I would troubleshoot the credentials/endpoint configuration first rather than AnyLogic itself.

    For IoT Hub, make sure you're using the Event Hubs-compatible endpoint information, not the normal IoT Hub device connection string. IoT Hub exposes its built-in endpoint so that standard Event Hubs SDKs can consume device-to-cloud messages.

    In the Azure portal, go to:

    IoT Hub → Built-in endpoints → Events

    Verify the following values against your application configuration:

    • Event Hub-compatible name
    • Event Hub-compatible endpoint
    • Consumer group - you're currently using $Default
    • Shared access policy/key being used by the consumer

    Also make sure the SAS policy has Service Connect/Listen permission. Event consumers need authorization to receive events; incorrect SAS credentials or permissions can result in authentication failures.

    One thing I'd specifically check in your code is the Event Hub name. A CBS Token authentication failed error can occur when the Event Hub name passed to the SDK is incorrect. Microsoft Q&A has documented cases where changing the value from a namespace/path to only the Event Hub name resolved this exact error.

    For example, conceptually:

    consumer = EventHubConsumerClient.from_connection_string(
        conn_str="<IoT Hub Event Hubs-compatible connection string>",
        consumer_group="$Default",
        eventhub_name="<Event Hub-compatible name>"
    )
    

    Don't use the IoT Hub name automatically as eventhub_name; use the Event Hub-compatible name shown under Built-in endpoints.

    I would also check IoT Hub → Networking. If IP filtering is configured and Apply IP filters to the built-in endpoint is enabled, the machine/service running your consumer must originate from an allowed address. Microsoft notes that blocked access to the built-in endpoint can result in an unauthorized response.

    If this still fails, please share the relevant connection code with the SharedAccessKey/SAS token removed, along with the Event Hub-compatible name and whether you're using SAS or Microsoft Entra authentication. That should help us identify exactly where the authentication mismatch is occurring.

    Sharing these references with you:

    Microsoft – Understand Azure IoT Hub endpoints

    Microsoft – Event Hubs authentication troubleshooting

    Microsoft – IoT Hub IP filtering

    Please "Accept the Answer" if this information helped you. This will help us and others in the community.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.