Azure / azure-service-bus-emulator-installer

This repository acts as a central hub for handling issues, collecting feedback, and facilitating discussions related to the Azure Service Bus Emulator.
https://learn.microsoft.com/en-us/azure/service-bus-messaging/overview-emulator
MIT License
100 stars 2 forks source link

ServiceBusAdministrationClient support #17

Open deadwards90 opened 1 day ago

deadwards90 commented 1 day ago

Our applications create their own queues / subscriptions on startup so that we don't have to manage that infrastructure elsewhere. We do this by interacting with Service Bus via ServiceBusAdministrationClient.

When trying to use that client in combination with the emulator you will see the following error:

Unhandled exception. System.AggregateException: Retry failed after 4 tries. Retry settings can be adjusted in ClientOptions.Retry or by configuring a custom retry policy in ClientOptions.RetryPolicy. (No connection could be made because the target machine actively refused it. (127.0.0.1:443)) (No connection could be made because the target machine actively refused it. (127.0.0.1:443)) (No connection could be made because the target machine actively refused it. (127.0.0.1:443)) (No connection could be made because the target machine actively refused it. (127.0.0.1:443))
 ---> Azure.RequestFailedException: No connection could be made because the target machine actively refused it. (127.0.0.1:443)
 ---> System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it. (127.0.0.1:443)
 ---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
   at System.Net.Sockets.Socket.<ConnectAsync>g__WaitForConnectWithCancellation|285_0(AwaitableSocketAsyncEventArgs saea, ValueTask connectTask, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnectionPool.ConnectToTcpHostAsync(String host, Int32 port, HttpRequestMessage initialRequest, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem)
   at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.WaitWithCancellationAsync(CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)        
   at Azure.Core.Pipeline.HttpClientTransport.ProcessSyncOrAsync(HttpMessage message, Boolean async)
   --- End of inner exception stack trace ---
   at Azure.Core.Pipeline.HttpClientTransport.ProcessSyncOrAsync(HttpMessage message, Boolean async)
   at Azure.Core.Pipeline.HttpPipelineTransportPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline)
   at Azure.Core.Pipeline.ResponseBodyPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
   at Azure.Core.Pipeline.RedirectPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
   at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
   --- End of inner exception stack trace ---
   at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory`1 pipeline, Boolean async)
   at Azure.Core.Pipeline.HttpPipeline.SendRequestAsync(Request request, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Administration.HttpRequestAndResponse.SendHttpRequestAsync(Request request, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Administration.HttpRequestAndResponse.GetEntityAsync(String entityPath, String query, Boolean enrich, CancellationToken cancellationToken)
   at Azure.Messaging.ServiceBus.Administration.HttpRequestAndResponse.GetEntitiesPageAsync[T](String path, String nextSkip, Func`2 parseFunction, CancellationToken cancellationToken)
   at Azure.Core.PageResponseEnumerator.FuncAsyncPageable`1.AsPages(String continuationToken, Nullable`1 pageSizeHint)+MoveNext()
   at Azure.Core.PageResponseEnumerator.FuncAsyncPageable`1.AsPages(String continuationToken, Nullable`1 pageSizeHint)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at Azure.AsyncPageable`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
   at Azure.AsyncPageable`1.GetAsyncEnumerator(CancellationToken cancellationToken)+MoveNext()
   at Azure.AsyncPageable`1.GetAsyncEnumerator(CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at Program.PublishMessageToDefaultQueue() in C:\Users\user\dev\temp\ServiceBusTest\ServiceBus.Emulator.Console.Sample\Program.cs:line 37
   at Program.PublishMessageToDefaultQueue() in C:\Users\user\dev\temp\ServiceBusTest\ServiceBus.Emulator.Console.Sample\Program.cs:line 37
   at Program.Main(String[] args) in C:\Users\user\dev\temp\ServiceBusTest\ServiceBus.Emulator.Console.Sample\Program.cs:line 15
   at Program.<Main>(String[] args)

I created this error by modifying the example with the following lines just after Main starts

var managementClient = new ServiceBusAdministrationClient(_connectionString);
await foreach(var page in managementClient.GetQueuesAsync())
{
    Console.WriteLine("Found page");
}

I'm guessing as of right now this client is just not supported. This is mentioned in the documentation but seems like a fairly major limitation.

This would be really useful to have.

gkinsman commented 1 day ago

It's mentioned in the learn.microsoft page here as a known limitation. Hopefully it'll be supported in the future, as many .NET middlewares work this way and don't support up-front configuration at all.

deadwards90 commented 1 day ago

Thanks @gkinsman, I missed that. I'll update the issue just to track support in that case.

Jeroen-Sturm commented 14 hours ago

+1 , wanted to add a RequiresDuplicateDetection queue to test some stuff, unfortunately it's not supported.