<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: dbutils.secrets.get- NoSuchElementException: None.get in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/dbutils-secrets-get-nosuchelementexception-none-get/m-p/13453#M8133</link>
    <description>&lt;P&gt;Howdy @Sandesh Puligundla​&amp;nbsp;- Thank you for your question. Thank you for your patience. I'd like to give this a bit longer to see how the community responds. Hang tight!&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 16:30:11 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-10-15T16:30:11Z</dc:date>
    <item>
      <title>dbutils.secrets.get- NoSuchElementException: None.get</title>
      <link>https://community.databricks.com/t5/data-engineering/dbutils-secrets-get-nosuchelementexception-none-get/m-p/13452#M8132</link>
      <description>&lt;P&gt;The below code executes a 'get' api method to retrieve objects from s3 and write to the data lake.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem arises when I use dbutils.secrets.get to get the keys required to establish the connection to s3&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;my_dataframe.rdd.foreachPartition(partition =&amp;gt; {
        val AccessKey = dbutils.secrets.get(scope = "ADB_Scope", key = "AccessKey-ID")
        val SecretKey = dbutils.secrets.get(scope = "ADB_Scope", key = "AccessKey-Secret") 
        val creds = new BasicAWSCredentials(AccessKey, SecretKey)
        val clientRegion: Regions = Regions.US_EAST_1
        val s3client  = AmazonS3ClientBuilder.standard()
        .withRegion(clientRegion)
        .withCredentials(new AWSStaticCredentialsProvider(creds))
        .build()
          partition.foreach(x =&amp;gt; {
            val objectKey = x.getString(0)
            val i = s3client.getObject(s3bucketName, objectKey).getObjectContent
            val inputS3String = IOUtils.toString(i, "UTF-8")
            val filePath = s"${data_lake_get_path}"
            val file = new File(filePath)
            val fileWriter = new FileWriter(file)
            val bw = new BufferedWriter(fileWriter)
            bw.write(inputS3String)
            bw.close()
            fileWriter.close()
          })
      })&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above results in the error:-&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;I&gt;Caused by: java.util.NoSuchElementException: None.get&lt;/I&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;	at scala.None$.get(Option.scala:529)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;	at scala.None$.get(Option.scala:527)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;	at com.databricks.dbutils_v1.&lt;/I&gt;&lt;A href="http://impl.SecretUtilsImpl.sc" alt="http://impl.SecretUtilsImpl.sc" target="_blank"&gt;&lt;I&gt;impl.SecretUtilsImpl.sc&lt;/I&gt;&lt;/A&gt;&lt;I&gt;$lzycompute(SecretUtilsImpl.scala:24)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;	at com.databricks.dbutils_v1.&lt;/I&gt;&lt;A href="http://impl.SecretUtilsImpl.sc" alt="http://impl.SecretUtilsImpl.sc" target="_blank"&gt;&lt;I&gt;impl.SecretUtilsImpl.sc&lt;/I&gt;&lt;/A&gt;&lt;I&gt;(SecretUtilsImpl.scala:24)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;	at com.databricks.dbutils_v1.impl.SecretUtilsImpl.getSecretManagerClient(SecretUtilsImpl.scala:36)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;	at com.databricks.dbutils_v1.impl.SecretUtilsImpl.getBytesInternal(SecretUtilsImpl.scala:46)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;	at com.databricks.dbutils_v1.impl.SecretUtilsImpl.get(SecretUtilsImpl.scala:61)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When the actual secret scope values for AccessKey and SecretKey are passed the above code works fine. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can this work using dbutils.secrets.get so that keys are not exposed in the code?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Oct 2021 05:33:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dbutils-secrets-get-nosuchelementexception-none-get/m-p/13452#M8132</guid>
      <dc:creator>Sandesh87</dc:creator>
      <dc:date>2021-10-14T05:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: dbutils.secrets.get- NoSuchElementException: None.get</title>
      <link>https://community.databricks.com/t5/data-engineering/dbutils-secrets-get-nosuchelementexception-none-get/m-p/13453#M8133</link>
      <description>&lt;P&gt;Howdy @Sandesh Puligundla​&amp;nbsp;- Thank you for your question. Thank you for your patience. I'd like to give this a bit longer to see how the community responds. Hang tight!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 16:30:11 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/dbutils-secrets-get-nosuchelementexception-none-get/m-p/13453#M8133</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-10-15T16:30:11Z</dc:date>
    </item>
  </channel>
</rss>

