title: Azure FileShare: The specified resource does not exist - SAS Authentication
body: <p>I am trying to list files under an Azure FileShare using a SAS in Java/ Scala.</p>
  
  <p>I do not have access to Storage Account, but only a SAS key for a particular share in Azure File Storage. How to directly access the Share  in Java?</p>
  
  <p>I am able to list the directories and files in the Share using Storage Explorer, download using AZCopy or Rest Call using the share url with SAS key.</p>
  
  <p>Almost everyone else posting with similar error has tried to authenticate using Storage Account Keys and for BlobStorage. They seem to have access to one level above the share, i.e the storage account. But I need to directly connect to the FileShare using SAS that works only for this share.</p>
  
  <pre><code>  val storageConnectionString =
    s"FileEndpoint=$endpoint;" + // https://xyz.file.core.windows.net
      "SharedAccessSignature=" +
      URLEncoder.encode(sas)
  
    val storageAccount = CloudStorageAccount.parse(storageConnectionString)
  
    val fileClient = storageAccount.createCloudFileClient()
    val share = fileClient.getShareReference(fshare)  //A fileshare with access
    val rootDir = share.getRootDirectoryReference()
    val files = rootDir.listFilesAndDirectories()
  
    files.forEach(file =&gt; println(file.getUri)) //Error: com.microsoft.azure.storage.StorageException: The specified resource does not exist.
  </code></pre>
  
  <p>The files in the Share are visible in UI of Storage Explorer using the same URI(FileShareEndpoint+"/"+fshare+"?"+sas).</p>
  
  <p>Expected to get a list of files and directories but getting exception: "The specified resource does not exist.". Is it the code or is it not possible through a program to connect to the share without first authenticating to the storage account?</p>