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

Commit 92c8bca

Browse files
author
David R. Williamson
authored
Fix entity path on F1 hubs (#44)
1 parent 59ec3fe commit 92c8bca

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

scripts/iot-hub-connection-string.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ async function convertIotHubToEventHubsConnectionString(connectionString) {
8080
const error = context.receiver && context.receiver.error;
8181
if (isAmqpError(error) && error.condition === "amqp:link:redirect") {
8282
const hostname = error.info && error.info.hostname;
83+
const parsedAddress = error.info.address.match(/5671\/(.*)\/\$management/i);
84+
8385
if (!hostname) {
8486
reject(error);
87+
} else if (parsedAddress == undefined || (parsedAddress && parsedAddress[1] == undefined)) {
88+
const msg = `Cannot parse the EventHub name from the given address: ${error.info.address} in the error: ` +
89+
`${error.stack}\n${JSON.stringify(error.info)}.\nThe parsed result is: ${JSON.stringify(parsedAddress)}.`;
90+
reject(Error(msg));
8591
} else {
86-
resolve(
87-
`Endpoint=sb://${hostname}/;EntityPath=${iotHubName};SharedAccessKeyName=${SharedAccessKeyName};SharedAccessKey=${SharedAccessKey}`
88-
);
92+
const entityPath = parsedAddress[1];
93+
resolve(`Endpoint=sb://${hostname}/;EntityPath=${entityPath};SharedAccessKeyName=${SharedAccessKeyName};SharedAccessKey=${SharedAccessKey}`);
8994
}
9095
} else {
9196
reject(error);

0 commit comments

Comments
 (0)