В настоящее время я создаю приложение и пытаюсь написать веб-задание, чтобы взять файл mp4, который я загрузил в хранилище BLOB-объектов, и создать ресурс, который затем я могу закодировать и подготовить к потоковой передаче с использованием мультимедийных служб Azure.
public class Functions
{
// This function will get triggered/executed when a new message is written
// on an Azure Queue called queue.
static string accName = "copied from portal ";
static string accKey = "as above";
static CloudMediaContext context = new CloudMediaContext(accName,accName);
// Use the cached credentials to create CloudMediaContext.
//static CloudMediaContext context = new CloudMediaContext(accName,accKey);
public static void ProcessVideo(
[QueueTrigger("videorequest")] VideoBlobInformation blobInfo,
[Blob("{ProfileId}/{BlobName}", FileAccess.Read)] Stream input,
[Blob("{ProfileId}/{BlobNameWithoutExtension}_stream.mp4")] CloudBlockBlob outputBlob)
{
VideoBlobInformation b = blobInfo;
using (Stream output = outputBlob.OpenWrite())
{
ConvertAndPrepareVideo(b,input, output);
}
// Entity Framework context class is not thread-safe, so it must
// be instantiated and disposed within the function.
using (impulsevidContext db = new impulsevidContext())
{
//var id = blobInfo.ProfileId;
//Video ad = db.Videos.Find(id);
//if (ad == null)
//{
// throw new Exception(String.Format("AdId {0} not found, can't create thumbnail", id.ToString()));
//}
//ad.StreamUrl = outputBlob.Uri.ToString();
//db.SaveChanges();
}
}
public static void ConvertAndPrepareVideo(VideoBlobInformation info,Stream input, Stream output)
{
var storageAccount = new CloudStorageAccount(new StorageCredentials("accnameofstorage", "storage account associated with azure media services"), true);
//output all webjob input blobs into a container -mediacontroller-
var cloudBlobClient = storageAccount.CreateCloudBlobClient();
var mediaBlobContainer = cloudBlobClient.GetContainerReference("impfile");
mediaBlobContainer.CreateIfNotExists();
IAsset sourceAsset = context.Assets.Where(a => a.Id == info.VideoId).First();
}
IAsset sourceAsset = context.Assets.Where(a => a.Id == info.VideoId).First();
что вызывает эту ошибку журнала
context = new CloudMediaContext (новые MediaServicesCredentials (accName, accKey)); должен быть установлен в методе ConvertAndPrepareVideo, а не за его пределами