All,
I inadvertently uninstalled EventHub V1.3.3 and installed the latest V5.0.0. I had to change the code that I had but I never got it to work. Below is the code:
from azure.eventhub import EventHubProducerClient, EventData
connection_str = 'Endpoint=sb://eventhubns20.servicebus.windows.net/;SharedAccessKeyName=eventhub20_pol;SharedAccessKey=xxxxxxxxxx=;EntityPath=eventhub20' eventhub_name = 'eventhub20'
client = EventHubProducerClient.from_connection_string(connection_str, eventhub_name=eventhub_name)
event_data_batch = client.create_batch()
Below is the error:
Traceback:
File "C:\Users\grajee\AppData\Local\Programs\Python\Python38-32\lib\site-packages\uamqp\authentication\cbs_auth.py", line 69, in create_authenticator
self._cbs_auth = c_uamqp.CBSTokenAuth(
File ".\src/cbs.pyx", line 73, in uamqp.c_uamqp.CBSTokenAuth.__cinit__
ValueError: Unable to open CBS link.
The error is on this line - event_data_batch = client.create_batch().
Has anyone experienced this error. If it is too much of work I might have to rollback to V1.3.3. The Python version is V3.8.1 on Windows.
Your connection string is incorrect. The one you are using is EventHub instance connection string, but you should use Eventhub Namespace connection string.
The correct Eventhub Namespace connection string looks like this: Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=policyName;SharedAccessKey=xxxx.
Please follow the step below to get the Event hub NameSpace connection string(not the event hub instance connection string).
Nav to azure portal -> your Azure EventHub NameSpace -> Shared access policies -> click the policy you want to use -> then copy the connection string from Connection string–primary key.
The screenshot as blow:

Your hostname doesn't resolve. Please make sure you are using an active Event hubs namespace.
>ping eventhubns20.servicebus.windows.net
Ping request could not find host eventhubns20.servicebus.windows.net. Please check the name and try again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With