question

EmilRbildBolet-6968 avatar image
0 Votes"
EmilRbildBolet-6968 asked EmilRbildBolet-6968 commented

Get message from a Service Bus topic using a Azure AD JWT using AMQP.Net Lite

Hi is it possible to use an Azure AD JWT to get messages from an Azure Service Bus topic through AMQP.Net Lite? We would like to manage who can access our Service bus topic by using Azure RBAC.
I have looked at https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-sas#use-the-shared-access-signature-at-amqp-level but it seems like its only possible with SAS tokens.

I have created an example(https://github.com/emilbolet/azure-servicebus-amqp-rbac) using the Microsoft.Azure.ServiceBus library however it is critical that we use a generic AMQP library.

azure-service-bus
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ClemensVasters-1924 avatar image
2 Votes"
ClemensVasters-1924 answered EmilRbildBolet-6968 commented

AMQP.Net Lite has a "CBS" sample that is important for this. You need to use the CBS mechanism to set these tokens. The sample shows SAS, you can use JWT instead: https://github.com/Azure/amqpnetlite/blob/master/Examples/ServiceBus/Scenarios/CbsAsyncExample.cs

To acquire the JWT, you need to request access to "https://servicebus.azure.net/.default" on AAD.

https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-managed-service-identity#overview

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @ClemensVasters-1924
Thanks for responding I have tried creating a CBS sender and receiver based on the information you send me.
However, I'm getting an error when trying to receive the message (which is the important part)
89811-image.png

The code i have created is available here
https://gist.github.com/emilbolet/0064a17ddde2e1e8d9afa7c58a367f9c


0 Votes 0 ·
image.png (21.0 KiB)

It's a bit odd that the name of the message entity reported back by the service is that whole string in single-quotes. What are you passing as the "topic" parameter?

0 Votes 0 ·

@ClemensVasters-1924 it is the name of our topic we want to subscribe to
89985-image.png


89910-image.png



0 Votes 0 ·
image.png (7.9 KiB)
image.png (35.5 KiB)