Search code examples
azureazure-media-services

Error when executing a sample code for Azure Media Service v3


I am following the sample for video uploading using Content-Aware via Azure Media Service SDK v3 in C#. But I am getting an error on the following line of code (https://github.com/Azure-Samples/media-services-v3-dotnet/blob/main/VideoEncoding/Encoding_H264_ContentAware/Program.cs#L266)

var sasUriCollection = asset.GetStorageContainerUrisAsync(
    new MediaAssetStorageContainerSasContent
    {
        Permissions = MediaAssetContainerPermission.ReadWrite,
        ExpireOn = DateTime.UtcNow.AddHours(1)
    });

var sasUri = await sasUriCollection.FirstOrDefaultAsync();

Not sure which library am I missing. Any pointers?


Solution

  • I ended up adding extension method.

    public static async Task<T> FirstOrDefaultAsync<T>(this IAsyncEnumerable<T> enumerable)
    {
        var enumerator = enumerable.GetAsyncEnumerator();
        await enumerator.MoveNextAsync();
        return enumerator.Current;
    }