Skip to content

Commit

Permalink
CB-28 Add logging to AzureFileService
Browse files Browse the repository at this point in the history
  • Loading branch information
izzat5233 committed Jan 15, 2025
1 parent 7b79d7f commit 7f1ea01
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ChatbotBuilderApi.Infrastructure/Files/AzureFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Azure.Storage.Blobs.Models;
using ChatbotBuilderApi.Application.Core.Abstract;
using ChatbotBuilderApi.Application.Core.Shared;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace ChatbotBuilderApi.Infrastructure.Files;
Expand All @@ -10,7 +11,9 @@ public sealed class AzureFileService : IFileService
{
private readonly BlobContainerClient _containerClient;

public AzureFileService(IOptions<AzureBlobStorageSettings> options)
public AzureFileService(
IOptions<AzureBlobStorageSettings> options,
ILogger<AzureFileService> logger)
{
var settings = options.Value ??
throw new ArgumentNullException(nameof(options));
Expand All @@ -20,6 +23,13 @@ public AzureFileService(IOptions<AzureBlobStorageSettings> options)
$"AccountKey={settings.AccountKey};" +
$"EndpointSuffix=core.windows.net";

logger.LogInformation("Azure Blob Storage with account name ending with {AccountNameEndsWith} " +
"and key ending with {AccountKeyEndsWith} " +
"and container name {ContainerName}",
settings.AccountName[^3..],
settings.AccountKey[^3..],
settings.ContainerName);

_containerClient = new BlobContainerClient(connectionString, settings.ContainerName);
_containerClient.CreateIfNotExists(PublicAccessType.Blob);
}
Expand Down

0 comments on commit 7f1ea01

Please sign in to comment.