通过 scala 应用程序读取 azure wasbs 中的文件

Read a file in azure wasbs through scala application

我的集群应该读取一些位于我的 Azure 存储中的输入文件。我正在通过 livy 将我的 .jar 提交到集群,但它总是死掉,因为我找不到我的文件 -> 用户 class 抛出异常:java.io.FileNotFoundException。我错过了什么? 我不想使用 sc.textFile 打开文件,因为它会使它们变成 RDD 结构,我需要它们的结构正确。

val Inputs : String = scala.io.Source.fromFile("wasbs:///inputs.txt").mkString

我认为我正在尝试从错误的位置或使用错误的方法读取,有什么想法吗?

谢谢!

根据你的描述,根据我的理解,我认为你想在 HDInsight 上使用 Scala 运行 将纯文本文件加载到 Azure 存储上。

根据我的经验,您可以尝试通过两种方式来实现您的需求。

  1. 只是在 Azure Java Storage SDK 中使用 Scala 获取文本 blob 的内容,请参考教程 How to use Blob storage from Java,我认为使用 Scala 重写教程中的示例代码非常简单。

  2. Hadoop Azure Support library to load file data, please refer to the hadoop example wiki https://wiki.apache.org/hadoop/HadoopDfsReadWriteExample 中使用 Hadoop 文件系统 API 在 Scala 中编写代码。