public async Task <FileDownloadInfo> DownloadFileAsync(string fileName) { var client = _blobClientFactory.GetContainerClient(AzureBlobConstants.BlobDocumentsContainerName); var lowerFileName = fileName.ToLower(); var blobClient = client.GetBlobClient(lowerFileName); var isBlobClientExists = await blobClient.ExistsAsync(); if (!isBlobClientExists) { _serviceLogger.LogWarning($"File '{fileName}' is not found in blob storage"); return(new FileDownloadInfo { Status = HttpStatusCode.NotFound.ToString("G"), Content = null, ContentType = string.Empty }); } var downloadResult = await blobClient.DownloadAsync(); using var downloadInfo = downloadResult.Value; using var rawResponse = downloadResult.GetRawResponse(); _serviceLogger.LogInfo($"File '{fileName}' download responded with status '{rawResponse.Status}-{rawResponse.ReasonPhrase}'"); return(new FileDownloadInfo { Status = rawResponse.ReasonPhrase, ContentType = downloadInfo.ContentType, Content = downloadInfo.Content }); }
public async Task InsertOrReplacePdfDocumentAsync(DocumentEntity document) { var documentClient = _documentClientFactory.GetClient(); var documentCollectionUri = UriFactory.CreateDocumentCollectionUri( CosmosDbConstants.DocumentsDatabaseId, CosmosDbConstants.PdfDocumentsCollectionId); _serviceLogger.LogInfo($"Upserting '{document.Id}' to data storage"); await documentClient.UpsertDocumentAsync(documentCollectionUri, document, disableAutomaticIdGeneration : true); }
public void LogInfo_LogMessageSentWithInformationLogLevel() { //Arrange var message = _fixture.Create <string>(); var serilogLoggerMock = new Mock <ISerilogLogger>(); _serviceLoggerFactoryMock .Setup(factory => factory.GetLogger()) .Returns(serilogLoggerMock.Object); //Act _sut.LogInfo(message); //Assert serilogLoggerMock .Verify(logger => logger.Write(LogEventLevel.Information, message), Times.Once); }