Closed tony-gutierrez closed 5 years ago
Apparently the SAS token constant for the connection string is never used in this SDK at all: https://github.com/Azure/azure-sdk-for-node/search?utf8=%E2%9C%93&q=SHARED_ACCESS_SIGNATURE_NAME&type=
@tony-gutierrez - Extremely sorry the bad experience. The azure-sb package is not being actively maintained. Have you given a try to the amqp protocol based amqp10 package. The maintainers of this package claim to be actively testing their package against Azure Eventhubs, Servicebus queues and topics amongst other servers. Moreover, AMQP protocol is faster and resilient than HTTP.
How are you as a company not maintaining an SDK for your own product????
We just hit this same issue with the sdk for both PHP and Node.
So I developed a workaround for connecting to SB with SAS tokens (via HTTPS, not AQMP) using the JS SDK. MS is a lost cause (they don't even have azure-node-sdk usage docs online, they are only in google cache: https://github.com/Azure/azure-sdk-for-node/issues/2291, https://github.com/Azure/azure-sdk-for-node/issues/2133) but maybe this will help someone.
You need to create a fake authenticationProvider class based of of the SAS auth provider class. Have it do nothing more than add the sas token to the header:
var azureCommon = require('azure-common');
var Constants = azureCommon.Constants;
var HeaderConstants = Constants.HeaderConstants;
function SharedAccessSignature(token) {
this.token = token;
}
SharedAccessSignature.prototype.signRequest = function (webResource, callback) {
webResource.withHeader(HeaderConstants.AUTHORIZATION, this.token);
callback(null);
};
module.exports = SharedAccessSignature;
Then to connect to the sb do this:
const azure = require('azure');
const authenticationProviderService = require('./authenticationProvider');
authenticationProvider = new authenticationProviderService(yourSAStoken);
serviceBusService = azure.createServiceBusService({
_serviceBusEndpointUri: 'https://xxxxxx.servicebus.windows.net' //HTTPS:// NOT SB://!!!
}, null, null, null, null, authenticationProvider);
You can periodically update the token in use by the authenticationProvider as well:
authenticationProvider = new authenticationProviderService(yourSAStoken);
I still don't know how to use AMQP with SAS tokens. I think it involves sending a token message to a special AQMP queue after connecting, but needless to say there is 0 official JS support from Microsoft, and absolutely nothing in the SDK.
Kudos @tony-gutierrez, will give it a shot!
Something like this in JS might serve for AQMP, please let me know if anyone comes up with Node code along these lines! I'd love to have it but don't have time at the moment to try for it.
http://amqpnetlite.codeplex.com/SourceControl/latest#Examples/ServiceBus/ServiceBus.Cbs/Program.cs
Any luck by@tony-gutierrez or anyone else in using SAS tokens with AMQP? I'm trying to solve the same problem...
I have recently published AzureEventHubs library in node.js that communicates over AMQP. Azure EventHubs is a subset of Azure ServiceBus (It is a service focused on efficient receive scenarios).
While developing the sdk for EventHubs, I got the CBS Auth working that uses SAS Tokens to authenticate with the Service.
This is the link to the CBS client. This is the link to the SAS Token provider.
Over the next couple of weeks I will be working on the V1 version of the azure service bus node.js client that communicates over AMQP. Hopefully that eases the pain that most of our customers have to go through for node.js.
I have it working with rhea, but would love to see it in the official sdk. Retry strategies can be tricky though.
Thanks @tony-gutierrez , I was able to get it working using your example here. Using the DescribedType on the cbs request body was what I was missing. @amarzavery looking forward to seeing this in the native SDK!
@davidh1004 Id go with Rhea, that amqp10 lib is a little buggy. I have code if needed.
+1
Please try out the new servicebus sdk npm i @azure/service-bus
.
Source code for the new servicebus sdk can be found here.
A sample to send a message to ServiceBus Queue uses SAS token auth. In future please open service bus related issues in the new repo https://github.com/Azure/azure-sdk-for-js
Please try out the new servicebus sdk
npm i @azure/service-bus
.Source code for the new servicebus sdk can be found here.
A sample to send a message to ServiceBus Queue uses SAS token auth. In future please open service bus related issues in the new repo https://github.com/Azure/azure-sdk-for-js
Yeah the link to the sample is invalid... 404
@amarzavery The link that you provided returns 404. Could you please update the link?
@Loreno10 , @onerob2000 - Please find all the samples over here https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/servicebus/service-bus/samples/typescript. People keep moving samples over a period of time. General tip, try moving some folders up in the url and you should be able to find it. Everything is open source!
It's bad enough that we have to scour the web to try to discover code for generating SAS tokens for service bus, but then I find out that they are basically useless as there is no support in the Nodejs sdk for actually using them?
Why do you make a big deal out of SAS authentication in all your docs and then not even build in support into the SDK??