'Make specific file or directory public in a File System set as PublicAccessType.None

I'm trying to upload a file to a specific Azure Data Lake directory and make it accessible on the internet.

The following code is a minimal example of how I'm uploading the file:

var serviceClient = new DataLakeServiceClient(connectionString);

var fileSystem = serviceClient.GetFileSystemClient("my-file-system");
await fileSystem.CreateIfNotExistsAsync();

var directoryClient = fileSystem.GetDirectoryClient("my-directory-1");
await directoryClient.CreateIfNotExistsAsync();

var fileClient = directoryClient.GetFileClient("my-file-1");
await fileClient.UploadAsync(contentStream);

Console.WriteLine(fileClient.Uri.AbsoluteUri);

When I request the URI in fileClient.Uri.AbsoluteUri Azure returns a 404 error.

I tried:

  • messing with DataLakeFileUploadOptions.Permissions when uploading the file content
  • messing with directoryClient.SetPermissionsAsync when creating the directory

But no luck so far.

In my use case any of the following two solutions is acceptable:

  • Make the file itself publicly available
  • Make all files inside my-directory-1 publicly available

It's not acceptable, however, to make the whole file system publicly available -- changing the file system's PublicAccessType isn't a viable solution.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source