Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
Fix entity path on F1 hubs (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
David R. Williamson authored Apr 20, 2020
1 parent 59ec3fe commit 92c8bca
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/iot-hub-connection-string.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,17 @@ async function convertIotHubToEventHubsConnectionString(connectionString) {
const error = context.receiver && context.receiver.error;
if (isAmqpError(error) && error.condition === "amqp:link:redirect") {
const hostname = error.info && error.info.hostname;
const parsedAddress = error.info.address.match(/5671\/(.*)\/\$management/i);

if (!hostname) {
reject(error);
} else if (parsedAddress == undefined || (parsedAddress && parsedAddress[1] == undefined)) {
const msg = `Cannot parse the EventHub name from the given address: ${error.info.address} in the error: ` +
`${error.stack}\n${JSON.stringify(error.info)}.\nThe parsed result is: ${JSON.stringify(parsedAddress)}.`;
reject(Error(msg));
} else {
resolve(
`Endpoint=sb://${hostname}/;EntityPath=${iotHubName};SharedAccessKeyName=${SharedAccessKeyName};SharedAccessKey=${SharedAccessKey}`
);
const entityPath = parsedAddress[1];
resolve(`Endpoint=sb://${hostname}/;EntityPath=${entityPath};SharedAccessKeyName=${SharedAccessKeyName};SharedAccessKey=${SharedAccessKey}`);
}
} else {
reject(error);
Expand Down

0 comments on commit 92c8bca

Please sign in to comment.