Last week, a new release of the Windows Azure Media Services (WAMS) Asset Replicator Tool was published on CodePlex. This September 2013 release includes the following changes:
- Code upgraded to use the latest Windows Azure Storage Client library (v2.1.0.0)
- Code upgraded to use the latest Windows Azure Media Services .NET SDK (v2.4.0.0)
- C# projects upgraded to target .NET Framework 4.5
- Cloud Service project upgraded to Windows Azure Tools v2.0
- NuGet package dependencies updated to their latest versions
- Support added to compare, replicate and verify FragBlob assets
- New approach to auto-replicate and auto-ignore assets based on metadata in the IAsset.AlternateId property using JSON format
As you can see, the most important changes are the last two items which I will go into more detail about below.
FragBlob support
FragBlob is a new storage format that will be used in an upcoming Windows Azure Media Services feature that is not yet available. In this new format, each Smooth Streaming fragment is written to storage as a separate blob in the asset’s container instead of grouping them together into Smooth Streaming PIFF files (ISMV’s/ISMA’s). Therefore, the Replicator has been updated to identify, compare, copy and verify this new FragBlob asset type.
Replicator metadata in IAsset.AlternateId property using JSON format
To decide whether or not an asset should be automatically replicated or ignored, the Replicator Tool needs to get some metadata from your assets. Currently the IAsset interface does not have a property to store custom metadata, so as a workaround the Replicator now uses the IAsset.AlternateId string property to store this metadata with a specific JSON format described below:
{
"alternateId":"my-custom-alternate-id",
"replicate":"No",
"data":"optional custom metadata"
}
The following are the expected fields in the JSON format:
- alternateId: this is the actual Alternate Id value for the asset that is used to identify and track assets in both data centers.
- replicate: this is a three-state flag that the replicator will use to determine whether or not it should take automatic action for the asset. The possible values are:
- No: the asset will be automatically ignored
- Auto: the asset will be automatically replicated
- Manual: no automatic action will be taken for this asset
Important: If the replicate field is not included in the IAsset.AlternateId (or if this property is not set at all – null value), the default value is No (asset automatically ignored).
- data: this is an optional field that you can use to store additional custom metadata for the asset.
The Replicator uses some extension methods for the IAsset interface to easily retrieve and set these values without having to deal with the JSON format. These extensions can be found in the Replicator.Core\Extensions\AssetUtilities.cs source code file.
Using these IAsset extension methods for the IAsset.AlternateId property, you can easily set the Replicator metadata in your media workflows as explained below:
- How to set the IAsset.AlternateId metadata for automatic replication
- How to set the IAsset.AlternateId metadata for manual replication
How to set the IAsset.AlternateId metadata for automatic replication
Once your asset is ready (for instance, after ingestion or a transcoding job) and you have successfully created an Origin locator for it, you need to set the alternateId and replicate fields as follows:
// Set the alternateId to track the asset in both WAMS accounts.
string alternateId = "my-custom-id";
asset.SetAlternateId(alternateId);
// Set the replicate flag to 'Auto' for automatic replication.
asset.SetReplicateFlag(ReplicateFlag.Auto);
// Update the asset to save the changes in the IAsset.AlternateId property.
asset.Update();
By setting the replicate field to ‘Auto‘, the Replicator will un-ignore the asset and automatically start copying it to the other WAMS account. When the copy operation is complete, both assets will be marked as verified if everything measures up OK; otherwise, it will report the differences/errors and the user will have to take manual action from the Replicator Dashboard (like manually forcing the copy again).
How to set the IAsset.AlternateId metadata for manual replication
Once your asset is ready and you have successfully created an Origin locator for it, you need to set the alternateId and replicate fields as follows:
// Set the alternateId to track the asset in both WAMS accounts.
// Make sure to use the same alternateId for the asset in the other WAMS account that you want to compare.
string alternateId = "my-custom-id";
asset.SetAlternateId(alternateId);
// Set the replicate flag to 'Manual' for manual replication.
asset.SetReplicateFlag(ReplicateFlag.Manual);
// Update the asset to save the changes in the IAsset.AlternateId property.
asset.Update();
By setting the replicate field to ‘Manual‘, the Replicator will un-ignore the asset and check if there is an asset in the other WASM account with the same alternateId field. If the Replicator finds one, it will compare both assets and mark them as verified if everything checks out OK; otherwise, it will report the differences and the user will have to take manual action from the Replicator Dashboard (like deleting one and forcing a copy of the other). This scenario is useful when comparing assets living in different WAMS accounts and generated from the same source.
Enjoy!