Skip to content

Instantly share code, notes, and snippets.

View nmackenzie's full-sized avatar

Neil Mackenzie nmackenzie

  • Microsoft
  • San Francisco, CA
View GitHub Profile
TableQuery<BookEntity> query =
(from book in bookTable.CreateQuery<BookEntity>()
where book.PartitionKey == "hardback"
select book).AsTableQuery<BookEntity>();
TableContinuationToken continuationToken = null;
do {
var queryResult = query.ExecuteSegmented(continuationToken);
foreach (BookEntity entity in queryResult) {
public TableQuerySegment<TElement>
ExecuteSegmented(TableContinuationToken continuationToken,
TableRequestOptions requestOptions = null,
OperationContext operationContext = null);
var query = (from book in bookTable.CreateQuery<BookEntity>()
where book.PartitionKey == "hardback"
select book).Take(10);
CloudStorageAccount storageAccount = new CloudStorageAccount(
new StorageCredentials(accountName, accountKey), true);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable bookTable = tableClient.GetTableReference("book");
var query = from book in bookTable.CreateQuery<BookEntity>()
where book.PartitionKey == "hardback"
select book;
private String GetStreamingUrl(IJob job)
{
IAsset assetToStream = job.OutputMediaAssets[0];
var theManifest =
from f in assetToStream.AssetFiles
where f.Name.EndsWith(".ism")
select f;
IAssetFile manifestFile = theManifest.First();
private List<String> GetDownloadAssetSasList(IJob job)
{
IAsset assetToDownload = job.OutputMediaAssets[0];
IAccessPolicy sharedAccessPolicy = context.AccessPolicies.Create(
"DownloadFor7DaysPolicy",
TimeSpan.FromDays(7),
AccessPermissions.Read
);
String inputAssetId = ASSET_ID;
IJob job = context.Jobs.Create("Encoding job");
// Note that there are two Windows Azure Media Encoder processors
IMediaProcessor processor = context.MediaProcessors
.Where(p => p.Name == "Windows Azure Media Encoder")
.ToList()
.OrderBy(p => new Version(p.Version))
.LastOrDefault();
@nmackenzie
nmackenzie / UploadFile
Last active December 24, 2015 08:59
WAMS code fragment
String pathToFile = PATH_TO_MEDIA_FILE;
String fileName = Path.GetFileName(pathToFile);
String assetName = "SOME ASSET NAME";
CloudMediaContext context = new CloudMediaContext(
ACCOUNT_NAME, ACCOUNT_KEY);
IAsset asset = context.Assets.Create(
assetName, AssetCreationOptions.None);
IAssetFile assetFile = asset.AssetFiles.Create(fileName);
assetFile.Upload(pathToFile);
@nmackenzie
nmackenzie / ListJobs
Created October 1, 2013 05:42
WAMS fragment
CloudMediaContext context =
new CloudMediaContext(ACCOUNT_NAME, ACCOUNT_KEY);
DateTime tenDaysAgo = DateTime.UtcNow.AddDays(-10);
var jobQuery =
from job in context.Jobs
where job.Created >= tenDaysAgo
select job;
List<IJob> jobs = jobQuery.ToList();
public void GetMessage(String queueName)
{
string requestMethod = "GET";
String urlPath = String.Format("{0}/messages", queueName);
String storageServiceVersion = "2012-02-12";
String dateInRfc1123Format = DateTime.UtcNow.ToString("R", CultureInfo.InvariantCulture);
String canonicalizedHeaders = String.Format(
"x-ms-date:{0}\nx-ms-version:{1}",