Delete azure media services asset

Posted: December 27, 2012 in Windows Azure
Tags: ,


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;


  1. Rahul says:

    Its very helpful..thanks

  2. Devendra says:

    Very nice and helpful Article.


  3. Anand says:

    Very Nice, I was looking for the same. Keep it up.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s