/// <summary> /// 1- upload in Blob storage /// 2- queue new message /// 3- Temporary cheat, wake up listening Azure functions (fire and forget) /// </summary> /// <param name="theFile"></param> /// <returns></returns> public async Task <string> UploadAsync(FileToCreateDto theFile) { if (theFile == null || String.IsNullOrEmpty(theFile.FileAsBase64) || theFile.SubmittedPicture == null || theFile.SubmittedPicture.Id == Guid.Empty) { throw new ArgumentNullException(); } //1- using var blobTask = UploadInBlobAsync(theFile); await blobTask; if (blobTask.IsCompletedSuccessfully) { theFile.SubmittedPicture.FullImageUrl = blobTask.Result; //2- using var getTask = _repo.GetSubmittedPicturesByIDAsync(theFile.SubmittedPicture.Id.ToString()); await getTask; if (getTask.IsCompletedSuccessfully) { var itemToQueue = _mapper.Map <HRSubmitPictureListItemDto>(getTask.Result); itemToQueue.FullImageUrl = blobTask.Result; using var queueTask = _queueService.OnNewImageAsync(itemToQueue); await queueTask; if (queueTask.IsCompletedSuccessfully) { //3- WakeUpAzureFunction(); return(blobTask.Result); } else { throw new Exception("UploadInBlobAsync fail"); } } else { throw new Exception("_repo.GetSubmittedPicturesByIDAsync fail"); } } else { throw new Exception("UploadInBlobAsync fail"); } }