1
votes

Im working through this guide using Azure Functions to commit IoTHub messages to Azure storage. I'm at section 5d, where I need to create a new Service Bus Connection string for my function, but whatever I use, including the format in the guide:

Endpoint=<Event Hub-compatible endpoint>;SharedAccessKeyName=iothubowner;SharedAccessKey=<Primary key>

I get the error:

Not a valid service bus connection string.

I’ve tried using the Event Hub-compatible endpoint from my IoT hub endpoints and also the connection string –- primary key from the access policy for iothubowner but again it rejects it.

I then created a new service bus and used that connection (see my answer below and initial optimism!) but when I tried to edit the function I get a 404 toast notification:

Function ($DeviceDataToStorage) Error: The listener for function 'Functions.DeviceDataToStorage' was unable to start. Microsoft.ServiceBus: The messaging entity 'Management operation failed. status-code: 404, status-description: The messaging entity 'sb://{MY SERVICE BUS CONNECTION STRING WHICH WAS ACCEPTED}/{EVENTHUBNAME}' could not be found..' could not be found.

Can anyone who has used Azure functions before advise what format this needs to be in or more importantly where exactly in the portal I can get this from?

2

2 Answers

3
votes

Thought I figured it out, but I hadn't. Here's what I thought worked, but it didn't

*

Its missing from the tutorial, but you need to manually create a new service bus endpoint (see https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dotnet-get-started-with-queues) and copy the CONNECTIONSTRING-PRIMARYKEY from the RootManageSharedAccessKey policy of Shared Access Policies.

*

0
votes

According to your description, I checked this issue. As Prepare for IoT Hub connection to read messages states that you need to construct the connection string for your IoT hub endpoint as follows:

Endpoint={Event Hub-compatible endpoint};SharedAccessKeyName=iothubowner;SharedAccessKey={Primary key}

Replace {Event Hub-compatible endpoint} with:

enter image description here

Replace {Primary key} with:

enter image description here

Not a valid service bus connection string.

I assumed that you encounter this error when you creating a new Event Hub connection as follows:

enter image description here

When you add new connection string for your Event Hub, it should look like as follows:

enter image description here

Note: I assumed that you have confused with Service Bus connection string and IoT Hub connection string.

Connection string for Service Bus:

Endpoint=sb://{your-servicebus-name}.servicebus.windows.net/;SharedAccessKeyName={SharedAccessKeyName};SharedAccessKey={SharedAccessKey}