List content of a directory in Spark code in Azure Synapse

Viewed 4223

In Databricks' Scala language, the command dbutils.fs.ls lists the content of a directory. However, I'm working on a notebook in Azure Synapse and it doesn't have dbutils package. What is a Spark command corresponding to dbutils.fs.ls?

%%scala
  dbutils.fs.ls("abfss://container@datalake.dfs.core.windows.net/outputs/wrangleddata")
%%spark
  // list the content of a directory. ????
1 Answers

Just use mssparkutils, it's a rough equivalent and the main documentation page is here. A simple example:

mssparkutils.fs.ls("/")
mssparkutils.fs.ls("abfss://container@datalake.dfs.core.windows.net/outputs/wrangleddata")
Related