Search code examples
c#azure-media-services

how to set AlternateId for an asset in azure media service?


I am trying to add some custom metadata to every video stored in azure media service. As part of this I am trying to change the value of AlternateId of an asset stored in Azure media service.

I could see that the key is available as part of IAsset


Solution

  • When you use the CloudMediaContext to Create or Encode an asset you are handed the asset back. At this point you can set the AlternateId and call Update.

          IAsset inputAsset = _mediaContext.Assets.CreateFromBlob(blob, 
                                storageCredentials, AssetCreationOptions.None);
    
          inputAsset.AlternateId = assetId.ToString();
          inputAsset.Update();