Welcome to Microsoft Q&A forum and thanks for posting your query.
The difference between the two methods is that "FileSystem.get" uses the default configuration (static) to access the Azure storage, while "path.getFileSystem" uses the configuration (custom) specified in the
path
object.
In your case, it seems like the default configuration is not set correctly, which is why it is throwing a FileNotFoundException. To resolve the issue, please make sure that the default configuration is set correctly to access the Azure storage. If the default configuration is not set correctly, you may encounter errors such as FileNotFoundException. It is recommended to use "path.getFileSystem" instead of "FileSystem.get" when working with the abfss connector, as it uses the configuration specified in the "spark.sparkContext.hadoopConfiguration" object. This ensures that the correct configuration is used to access the Azure storage.
Given that the path.getFileSystem()
method is working and the FileSystem.get()
is not, it is likely that the issue is due to the configuration settings used. You can try to fix this issue by setting the same or similar configuration settings for both methods. (Please try to use the path
settings as your default settings and see if that helps to resolve the issue)
For more helpful info, please refer to this SO thread: Hadoop: Path.getFileSystem vs FileSystem.get
Hope this info helps.
Please don’t forget to Accept Answer
and Up-Vote
wherever the information provided helps you, this can be beneficial to other community members.