public async Task SendDownloadEventImageMessageAsync(Guid cfpPublicId, string cfpEventImageUrl) { Guard.IsNotNull(cfpEventImageUrl, nameof(cfpEventImageUrl)); var downloadEventImageModel = new DownloadEventImageMessage { Id = cfpPublicId, ImageUrl = cfpEventImageUrl }; var messageBody = JsonConvert.SerializeObject(downloadEventImageModel); var message = new Message(Encoding.UTF8.GetBytes(messageBody)); await _downloadImageQueueClient.SendAsync(message); }
public async Task SendDownloadEventImageMessageAsync(Guid cfpPublicId, string cfpEventImageUrl) { var servicebusConnectionstring = _configuration["ServicebusEventImagesQueueConnectionString"]; var queueClient = new QueueClient( new ServiceBusConnectionStringBuilder(servicebusConnectionstring), ReceiveMode.ReceiveAndDelete); var downloadEventImageModel = new DownloadEventImageMessage { Id = cfpPublicId, ImageUrl = cfpEventImageUrl }; var messageBody = JsonConvert.SerializeObject(downloadEventImageModel); var message = new Message(Encoding.UTF8.GetBytes(messageBody)); await queueClient.SendAsync(message); }
public async Task Run( [ServiceBusTrigger(Constants.QUEUE_IMAGES, Connection = "ServicebusQueueConnectionString")] DownloadEventImageMessage eventImageMessage, ILogger log) { log.LogInformation($"Processing the download event image for identifier `{eventImageMessage.Id}`"); if (Uri.IsWellFormedUriString(eventImageMessage.ImageUrl, UriKind.Absolute)) { log.LogInformation($"Event image URL is `{eventImageMessage.ImageUrl}`."); var relativeLocationOfStoredImage = await _storageService.StoreEventImageInBlobStorageAsync(eventImageMessage.ImageUrl, eventImageMessage.Id); if (!eventImageMessage.HasDefaultImage()) { _storageService.UpdateRecordInTheCfpRepository(eventImageMessage.Id, relativeLocationOfStoredImage); } } else { log.LogWarning($"The location `{eventImageMessage.ImageUrl}` for CFP `{eventImageMessage.Id}` is not an absolute URI."); } log.LogInformation($"Done processing the download event image for identifier `{eventImageMessage.Id}`"); }