Skip to content

Commit

Permalink
modified the Monitor job comment
Browse files Browse the repository at this point in the history
  • Loading branch information
John Deutscher committed Apr 17, 2017
1 parent 66f1528 commit 3576f00
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
5 changes: 4 additions & 1 deletion 100-basic-encoding/encode-blob-adaptive-stream/run.csx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ public static void Run(CloudBlockBlob inputBlob, string fileName, string fileExt
job.Submit();
log.Info("Job Submitted");

// Step 3: Monitor the Job
// Step 3: Monitor the Job
// ** NOTE: We could just monitor in this function, or create another function that monitors the Queue
// or WebHook based notifications. See the Notification_Webhook_Function project.
// For any job that takes longer than 5 minutes, Functions will die, so it is better to monitor
// long running encode jobs in a seperate function, or use WebHook Notifications
// from Media Services

while (true)
{
Expand Down
8 changes: 6 additions & 2 deletions 100-basic-encoding/encode-blob-multiIn-overlay/run.csx
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,13 @@ public static void Run(CloudBlockBlob inputBlob, TraceWriter log, string fileNam
job.Submit();
log.Info("Job Submitted");

// Step 3: Monitor the Job
// Step 3: Monitor the Job
// ** NOTE: We could just monitor in this function, or create another function that monitors the Queue
// or WebHook based notifications. We should create both samples in this project.
// or WebHook based notifications. See the Notification_Webhook_Function project.
// For any job that takes longer than 5 minutes, Functions will die, so it is better to monitor
// long running encode jobs in a seperate function, or use WebHook Notifications
// from Media Services

while (true)
{
job.Refresh();
Expand Down
3 changes: 3 additions & 0 deletions 100-basic-encoding/encode-blob-singleInput/run.csx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public static void Run(CloudBlockBlob inputBlob, string fileName, string fileExt
// Step 3: Monitor the Job
// ** NOTE: We could just monitor in this function, or create another function that monitors the Queue
// or WebHook based notifications. See the Notification_Webhook_Function project.
// For any job that takes longer than 5 minutes, Functions will die, so it is better to monitor
// long running encode jobs in a seperate function, or use WebHook Notifications
// from Media Services

while (true)
{
Expand Down
31 changes: 8 additions & 23 deletions 103-aspera-ingest/ingest-asset-encode/run.csx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,11 @@ public static void Run(CloudBlockBlob inputBlob, string fileName, string fileExt

IAsset newAsset = CreateAssetFromBlob(inputBlob, fileName, log).GetAwaiter().GetResult();
log.Info("Aspera Ingest: Asset created:" + newAsset.Id);

log.Info("Deleting the source asset from the input container");
inputBlob.DeleteIfExists();

// Step 2: Create an Encoding Job
// Step 2: Create an Encoding Job and then exit the function.

// Declare a new encoding job with the Standard encoder
IJob job = _context.Jobs.Create("Function - Encode blob single input");
Expand Down Expand Up @@ -102,29 +105,11 @@ public static void Run(CloudBlockBlob inputBlob, string fileName, string fileExt
// Step 3: Monitor the Job
// ** NOTE: We could just monitor in this function, or create another function that monitors the Queue
// or WebHook based notifications. See the Notification_Webhook_Function project.
// For any job that takes longer than 5 minutes, Functions will die, so it is better to monitor
// long running encode jobs in a seperate function, or use WebHook Notifications
// from Media Services

while (true)
{
job.Refresh();
// Refresh every 5 seconds
Thread.Sleep(5000);
log.Info($"Job ID:{job.Id} State: {job.State.ToString()}");

if (job.State == JobState.Error || job.State == JobState.Finished || job.State == JobState.Canceled)
break;
}

if (job.State == JobState.Finished)
log.Info($"Job {job.Id} is complete.");
else if (job.State == JobState.Error)
{
log.Error("Job Failed with Error. ");
throw new Exception("Job failed encoding .");
}
log.Info("Deleting the source asset from the input container");
inputBlob.DeleteIfExists();

log.Info("Aspera Ingest and Adaptive Bitrate Encode Complete!");
log.Info("Aspera Ingest Complete, Adaptive Bitrate Encode job is queued!");

}
catch (Exception ex)
Expand Down

0 comments on commit 3576f00

Please sign in to comment.