this is the test code removed sensetive credentials
package com.mycompany.hayden;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
import java.util.HashMap;
public class TestReadAzureCSV {
public static void main(String[] args) {
SparkSession spark = SparkSession.builder()
.appName("ReadAzureBlobCSVWithSAS")
.getOrCreate();
String storageAccount = "abc";
String containerName = "abc";
String sasToken = "abc";
String domain = "blob.core.windows.net"; //"z23.blob.storage.azure.net";
spark.conf().set(String.format("fs.azure.account.auth.type.%s.%s",storageAccount, domain), "SAS");
spark.conf().set(String.format("fs.azure.sas.%s.%s.%s", containerName,storageAccount, domain), sasToken);
spark.sparkContext().hadoopConfiguration().set(String.format("fs.azure.sas.%s.%s.%s", containerName,storageAccount, domain), sasToken);
String csvFilePath = "wasbs://xxx.csv";
Dataset<Row> df = spark.read()
.option("header", "true")
.option("inferSchema", "true")
.csv(csvFilePath);
df.show(true);
}
}
when I debug locally this is the method name entered.