Search code examples
c#asp.net-mvcazureazure-media-services

Cannot Publish Encoded Asset in Azure Media Services


I'm having a problem publishing an encoded asset in Azure Media Services.

I can see that my asset is being created and encoded because it displays in my Media Services account but the "publish" functionality fails. I can successfully publish any asset that is created and encoded by my application, by hitting the publish button in the portal. However, I need to be able to do it programmatically. This is my method. I don't get any errors...

   `private static IAsset PublishAsset(IJob job)
    {
        var preparedAsset = job.OutputMediaAssets.FirstOrDefault();
        var ismAssetFiles = preparedAsset.AssetFiles.ToList().
          Where(f => f.Name.EndsWith(".ism", StringComparison.OrdinalIgnoreCase))
          .ToArray();

        ismAssetFiles.First().IsPrimary = true;
        ismAssetFiles.First().Update();
        return preparedAsset;

    }`

Can anyone see what I'm doing wrong?


Solution

  • The pasted code does not publish the asset but only mark the .ism file as primary file in the asset.

    To publish the asset, you should create an access locator as explained here: https://azure.microsoft.com/en-us/documentation/articles/media-services-dotnet-get-started/#publish-the-asset-and-get-urls-for-streaming-and-progressive-download