0

I am connecting to Azure Service Bus using ServiceBusClient class. We are autheitcating with Azure using Azure AD (which uses oAuth 2.0).

Following code is been used.

 string connectionString = "Endpoint=sb://sb-test-new.servicebus.windows.net/;SharedAccessKeyName=manage;SharedAccessKey=8e+6SeDlwH6ufGEainEs6SZHbpJzDywz5DU=;";
        string topicName = "topic";
        string subscriptionName = "subone";
        TokenCredential credential = new ClientSecretCredential("fd8a7sdde-ccb1-4171-8626-1f9b2fcbfc2a", "40f8961f-c71e-4409-8961-2e89617304", "dkU8Q~R8961yP_2LIgdRVHWQtD42u-OabV");

        var options = new ServiceBusClientOptions
        {
            TransportType = ServiceBusTransportType.AmqpWebSockets,
            //RetryOptions = new ServiceBusRetryOptions()
            //{
            //    Mode = ServiceBusRetryMode.Exponential,
            //    CustomRetryPolicy = new MyRetryPolicy(),
            //},

            WebProxy = new WebProxy("http://127.0.0.1:8888", false)
            {
                UseDefaultCredentials = true
            }
        };

        await using var client = new ServiceBusClient("sb-test-new.servicebus.windows.net", credential);

        try
        {
  
            ServiceBusReceiver receiver = client.CreateReceiver(topicName, subscriptionName);

                         ServiceBusReceivedMessage receivedMessage = await receiver.ReceiveMessageAsync();

            string body = receivedMessage.Body.ToString();
            Console.WriteLine(body);
           

        }
        catch (Exception e)
        {
            
        }
    }

Issue: Fiddler is capturing calls made initially to authenticate the client and to get the refresh token. But is it not subsequent call (to send or receive message between client and service bus).

I tried adding following code but no luck:

var options = new ServiceBusClientOptions
        {
            TransportType = ServiceBusTransportType.AmqpWebSockets,
               
            WebProxy = new WebProxy("http://127.0.0.1:8888", false)
            {
                UseDefaultCredentials = true
            }
        };

        await using var client = new ServiceBusClient("sb-test-new.servicebus.windows.net", credential, options);

enter image description here

Robert
  • 39,162
  • 17
  • 99
  • 152
OpenStack
  • 5,048
  • 9
  • 34
  • 69

0 Answers0