Q:

Convert IBuffer to IRandomAccessStream

I know I can convert an IBuffer to a Stream and then from there to an IRandomAccessStream. But there must be a direct way.

A:

IBuffer is not a stream, so you need to have something to adapt one to the other. In .NET, you can use Stream.
IBuffer buffer = ...;
IRandomAccessStream randomAccessStream = buffer.AsStream().AsRandomAccessStream();

If it pains you to write the two function calls, you can write a helper function.
static IRandomAccessStream AsRandomAccessStream(this IBuffer buffer)
{
    return buffer.AsStream().AsRandomAccessStream();
}

then you can do
IBuffer buffer = ...;
IRandomAccessStream randomAccessStream = buffer.AsRandomAccessStream();

