Posts Tagged ‘Delete Asset’


I am going to show you how to delete a asset from Azure Media Services.

Step 1 : Connect to media services context.

CloudMediaContext _context = new CloudMediaContext(_accountName, _accountKey);

Step 2 : Get the assest from the media context. We will pass the asset name to get and delete the asset.

string assetName = "myasset_mp4";

IAsset assetToDelete = GetAsset(assetName);

//Now delete the asset

// Verify asset deletion
if (GetAsset(asset.Name) == null)
Console.WriteLine("Deleted the Asset.");

Step 3 : GetAsset function.

private IAsset GetAsset(string assetName)
// LINQ Select query to get an asset.
var assetInstance =
from a in _context.Assets
where a.Name == assetName
select a;

// Reference the asset as an IAsset.
IAsset asset = assetInstance.FirstOrDefault();

return asset;