Creating Items in Datalake creates a additional 0kb file with folder name or filename

Varun Nair 1 Reputation point
2021-03-23T05:43:06.1+00:00

We have created two Gen 2 storage account. Creating an item in one data lake container creates a 0 KB file with the same name as that of the file or folder. Attached the screen shot of the container items with the additional file that is created and below is the code that creates the directory and items in it.

Note:- The same code in another storage account in the same subscription does not create this additional file.

80453-image.png

   public static async Task StoreTobigatewaygen2(string path, string filename, byte[] barray)  
    {  
        try  
        {                  
            var fullpath = $"tagdata-full/";  
            string directoryname = $"{fullpath}{path}";  
            StorageSharedKeyCredential sharedKeyCredential = new StorageSharedKeyCredential(_accountName, _accountKey);  
            string dfsUri = "https://" + _accountName + ".blob.core.windows.net";  
            DataLakeServiceClient dataLakeServiceClient = new DataLakeServiceClient(new Uri(dfsUri), sharedKeyCredential);  
            DataLakeFileSystemClient fileSystemClient = dataLakeServiceClient.GetFileSystemClient(_fileSystemName);  
            DataLakeFileClient fileClient = fileSystemClient.GetFileClient(directoryname + @"/" + filename);  
            if (!fileClient.Exists(default) || fileClient.GetProperties().Value.CreatedOn < FirstRun.DT)  
            {  
                fileClient = await fileSystemClient.CreateFileAsync(directoryname + @"/"+ filename);  
                offset = 0;  
            }  
            else  
            {  
                offset = fileClient.GetProperties().Value.ContentLength;  
            }                  
            using (MemoryStream memorystream = new MemoryStream(barray))  
            {  
                fileClient.Append(memorystream, offset: offset);  
                fileClient.Flush(position: offset + barray.Length);  
            }  
            return;  
        }  
        catch (Exception ex)  
        {  
            Console.WriteLine(ex.Message);  
        }  
    }
Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,485 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Varun Nair 1 Reputation point
    2021-04-02T14:36:06.43+00:00

    Hi

    I have got a reply from Microsoft support team. The 0 KB file is created because the datalake is not Gen2 storage account as the hierarchical namespace was not enabled. So this storage account will use a flat structure causing a zero kb file to occur.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.