Пример #1
0
 public static async Task Run(
     [QueueTrigger(QueueNames.DownloadCoursePage, Connection = "AzureWebJobsStorage")] DownloadCourseMessage message,
     [Blob("downloads/course/{WebsiteDomain}{WebsitePath}.html", Connection = "AzureWebJobsStorage")] CloudBlockBlob htmlBlockBlob,
     ILogger logger,
     CancellationToken cancellationToken)
 {
     await Container.Instance.Resolve <DownloadCourseFunction>(logger).Run(message, htmlBlockBlob, cancellationToken);
 }
Пример #2
0
        private async Task Run(DownloadCourseMessage message, CloudBlockBlob htmlBlockBlob, CancellationToken cancellationToken)
        {
            using (var stream = await _downloader.DownloadAsync(message.WebsiteDomain, message.WebsitePath, cancellationToken)
                                .ConfigureAwait(false))
            {
                using (var ms = new MemoryStream())
                {
                    await stream.CopyToAsync(ms)
                    .ConfigureAwait(false);

                    await _cloudBlockBlobUpdater.UpdateAsync(htmlBlockBlob, ms.ToArray())
                    .ConfigureAwait(false);
                }
            }
        }