Search code examples
c#azurevideoazure-media-servicesblobstorage

Uploading video file from azure blob storage to azure media services


I have a web api where i upload .mp4 files to my blob storage account on Azure which is connected to my media services account. I want to copy the video from my storage account and upload it to my media services account. What i've tried so far is to get the filepath that points to my storage account file and do it like this:

  public void UploadToMediaServices(Uri storageAddress)
        {
            var filePath = storageAddress.ToString();
            var context = new CloudMediaContext("Name", "Key");
            var uploadAsset = context.Assets.Create(Path.GetFileNameWithoutExtension(filePath), AssetCreationOptions.None);
            var assetFile = uploadAsset.AssetFiles.Create(Path.GetFileName(filePath));
            assetFile.Upload(filePath);
        }

This is what azure websites recomended in their code snippet. The only thing is that i assume they take form local disk. When i do this it uploads a name to the media service but nothing else is available and i can't publish the video nor see the size of it. Does anyone know what to do in this situation? Thanks.


Solution

  • I assume you want to copy media files from your storage account into the storage account you attached to Azure Media Services. We have an article online to help you with that: https://msdn.microsoft.com/en-us/library/azure/jj933290.aspx. Please let me know whether it works for you.

    Thanks, Mingfei Yan