Monday 5 March 2018

Automation Process - Azure Storage Account To Azure Media Service Encoding Process




Today, I would like to share detail on automation process that we implemented in our recent development work.

I split blog in three division so that it would help for better understanding. 

Problem Statement:

We had implemented Cloud service for existing library files to process Azure media encoding and transcribing process so that it processed all the thousands of files successfully.

Now- Based on new requirement end user would upload files from the web application and that newly uploaded files would store in Azure Storage account.

We have to reuse existing cloud service source code logic so that it would process new uploaded media file for encoding and transcribing job.


The solution we design:

As we approach Azure function and mediator to communicate cloud service, new media upload.
Below is the high-level cross-functional diagram.



Actual Implementation: 

Azure functions is a solution for easily running small pieces of code in the cloud. we can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it. 

We have implemented an Azure function in a language of choice, such as C#, F#, Node.js, Java, or PHP. 

We created in C# as per below code snippet so that once new blob upload from web to storage account it would auto trigger and send a message to blob queue.

#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage.Blob;
using Microsoft.WindowsAzure.Storage.Queue;

public static void Run(CloudBlockBlob myBlob, string name, ICollector<string> blobQueueItem, TraceWriter log)
{
log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n URI: {myBlob.Uri} ");
blobQueueItem.Add(myBlob.Uri.ToString());
}


On other ends Cloud, service would de-queue message and send new uploaded assets to process encoding and transcribing service.


 CloudBlobClient sourceCloudBlobClient = sourceStorageAccount.CreateCloudBlobClient();
CloudBlobContainer sourceContainer = sourceCloudBlobClient.GetContainerReference(AppConfiguration.SourceBlobContainerName);
CloudBlobClient amsCloudBlobClient = amsStorageAccount.CreateCloudBlobClient();

 CloudQueue AzureCloudQueue = AzureQueueClient.GetQueueReference(AppConfiguration.blobqueuename);
 var azureQueueMessageList = AzureCloudQueue.GetMessages();


I request you to share your thoughts on the same and I would really appreciate if you could provide your valuable feedback.

Thanks!!! 

Xamarin - Cross Platform Mobile Development

Xamarin - Cross Platform Mobile Development Xamarin is one of the most popular cross-platform frameworks at the moment. Xamarin devel...