Exception Occurs while uploading video on Azure Media Serives

Category: azure media services


Usman Bajwa on Fri, 28 Oct 2016 05:11:57

I want uploading file on media services. When I upload file it gives exception after some time. here is the exception

Remote Server returns 500 Internal Server Error

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.WindowsAzure.MediaServices.Client.AssetFileData.Upload(String path)
at OnDemandEncoding.Models.Azure.UploadFile(String filePath) in C:\Users\Usman Bajwa\Desktop\Cloud Tech\OnDemandEncoding\OnDemandEncoding\Models\Azure.cs:line 49

Here is my uploading code: I am geeting exception at    assetFile.Upload(filePath);  

 public static string UploadFile(string filePath)
            string assetId = null;
                CloudMediaContext _context = GetContext();

                string assetName = Path.GetFileNameWithoutExtension(filePath);
                IAsset Asset = _context.Assets.Create(assetName, AssetCreationOptions.None);
                Console.Error.Write("Asset Created");
                IAssetFile assetFile = Asset.AssetFiles.Create(Path.GetFileName(filePath));
                var policy = _context.AccessPolicies.Create(
                                        AccessPermissions.Write | AccessPermissions.List);
                ILocator locator = _context.Locators.CreateLocator(LocatorType.Sas, Asset, policy);
                Console.Error.Write("Uploading File");

                assetFile.Upload(filePath);      // Getting Exception at this line 


                return assetId = assetFile.Asset.Id;

            catch (Exception e)
                return e.Message;


Wendy Zang on Fri, 28 Oct 2016 07:37:20

Hi Usman Bajwa,

Thank you for posting here.

Since your problem is more related to Azure Media Service, I will move it to Azure Media Services Forum for support.

The Visual C# forum discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

If you have some grammar or code errors, please feel free to contact us. We will try our best to give you a solution.

Thanks for your understanding and cooperation.

Best Regards,