To generate random bytes in WinRT, we need to use the APIs provided in Windows.Security.Cryptography.CryptographicBuffer

Use the following codes to generate a random buffer:

Windows.Security.Cryptography.CryptographicBuffer.GenerateRandom(length);

And use the IBuffer.ToArray() to convert the random buffer into byte array.
Like this:

Windows.Security.Cryptography.CryptographicBuffer.GenerateRandom(length).ToArray();

The equivalent legacy .NET codes can be written like this:

RandomNumberGenerator random = new RNGCryptoServiceProvider();
random.GetBytes(byteArray);