diff --git a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Amqp/AmqpMessageConverter.cs b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Amqp/AmqpMessageConverter.cs index 3f0a6b7e9f4d0..fb78f6847b87e 100644 --- a/sdk/servicebus/Azure.Messaging.ServiceBus/src/Amqp/AmqpMessageConverter.cs +++ b/sdk/servicebus/Azure.Messaging.ServiceBus/src/Amqp/AmqpMessageConverter.cs @@ -139,10 +139,17 @@ private static ArraySegment ReadStreamToArraySegment(Stream stream) return new ArraySegment(); } - using var memStream = new MemoryStream(StreamBufferSizeInBytes); - stream.CopyTo(memStream, StreamBufferSizeInBytes); - - return new ArraySegment(memStream.ToArray()); + switch (stream) + { + case BufferListStream bufferListStream: + return bufferListStream.ReadBytes((int)stream.Length); + default: + { + using var memStream = new MemoryStream(StreamBufferSizeInBytes); + stream.CopyTo(memStream, StreamBufferSizeInBytes); + return new ArraySegment(memStream.ToArray()); + } + } } public static AmqpMessage SBMessageToAmqpMessage(SBMessage sbMessage)