I am having some problems with the Azure Media Service. I have successfully managed to upload a file to Azure Media Service and encoded it as mp4, but this will only work on localhost in visual studio. When I deploy the following code to a Azure Virtual Machine, Windows Datacenter 2012 edition, the file is uploaded but the encoding job is never created.
Any help is much appreciated!
This is the code I use to create the job:
// Declare a new job.
job= _context.Jobs.Create("New Job");
// Get a media processor reference, and pass to it the name of the
// processor to use for the specific task.
IMediaProcessor processor = GetLatestMediaProcessorByName("Windows Azure Media Encoder");
// Create a task with the encoding details, using a string preset.
ITask task = job.Tasks.AddNew("LSVEncodingTask_" + v.CompanyId + "_user" + v.UserId,
processor,
"H264 Broadband 1080p",
TaskOptions.ProtectedConfiguration);
// Specify the input asset to be encoded.
task.InputAssets.Add(asset);
// Add an output asset to contain the results of the job.
// This output is specified as AssetCreationOptions.None, which
// means the output asset is not encrypted.
task.OutputAssets.AddNew("output asset",
AssetCreationOptions.None);
// Use the following event handler to check job progress.
job.StateChanged += new
EventHandler<JobStateChangedEventArgs>(StateChanged);
// Launch the job.
job.Submit();
// Check job execution and wait for job to finish.
Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);
EDIT:
Did some digging (logging...) and found the stack trace:
System.Security.Cryptography.CryptographicException: Access is denied.
at System.Security.Cryptography.X509Certificates.X509Store.Open(OpenFlags flags)
at Microsoft.WindowsAzure.MediaServices.Client.EncryptionUtils.SaveCertificateToStore(X509Certificate2 certToStore)
at Microsoft.WindowsAzure.MediaServices.Client.ContentKeyBaseCollection.GetCertificateForProtectionKeyId(IMediaDataServiceContext dataContext, String protectionKeyId)
at Microsoft.WindowsAzure.MediaServices.Client.JobData.ProtectTaskConfiguration(TaskData task, X509Certificate2& certToUse, IMediaDataServiceContext dataContext)
at Microsoft.WindowsAzure.MediaServices.Client.JobData.InnerSubmit(IMediaDataServiceContext dataContext)
at Microsoft.WindowsAzure.MediaServices.Client.JobData.SubmitAsync()
at Microsoft.WindowsAzure.MediaServices.Client.JobData.Submit()
at Livescreen.Domain.Implementation.AzureMediaManager.CreateEncodingJob(IAsset asset, String inputMediaFilePath, String outputFolder, Int32 videoId)
The solution was found here:
When running on IIS7 - you can specify to load the user profile of the App Pool. This gives you access to the per user store of the app pool account.
Solution: