0

I have a organization internal fileshare which is NAS(Network attached storage) based. I need to watch fileshare subfolder and what ever files or folders added to it should be reflected in azure storage container.

I tried below,

  BlobServiceClient blobServiceClient = new 
  BlobServiceClient(_settings.BlobSconnectionString);

            // Create the container and return a container client object
            BlobContainerClient containerClient =
                blobServiceClient.GetBlobContainerClient(containerName);

            // Get a reference to a blob
            BlobClient blobClient = containerClient.GetBlobClient(fileName);

            Console.WriteLine("Uploading to Blob storage as blob:\n\t {0}\n", blobClient.Uri);

            // Upload data from the local file
            await blobClient.UploadAsync(localFilePath, true);

this solution seems to work only for local machine files

  1. https://azure.microsoft.com/en-us/resources/templates/logic-app-ftp-to-blob/

But not sure above solution is correct because it is FTP and my file share is NAS based. so connection failed.

any idea how to do this?

Mahesh
  • 823
  • 1
  • 11
  • 29
  • 1
    No matter whether the file is in from local disk or from a mapped network drive/NAS, you should be able to get a stream reference to it and then use the `UploadAsync` method..use the one that takes the first argument as `Stream` – Anand Sowmithiran Jun 10 '22 at 06:48

1 Answers1

0

Like @Anand Sowmithiran suggested below working,

 string strFilePath = $"{folderPath}\\{fileName}";

 using (var stream = File.OpenRead(strFilePath))
 {
    await blobClient.UploadAsync(stream);
 }
Mahesh
  • 823
  • 1
  • 11
  • 29