The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Anyone else having this issue or potential work arounds to write/overwrite secrets from fabric notebook to azure key vault?
It seems that the below code works when I use PyTridentTokenLibrary and mssparkutils it works successfuly but only on getting a token.
`import requests`
`from azure.keyvault.secrets import SecretClient`
`from trident_token_library_wrapper import PyTridentTokenLibrary as tl`
`from azure.identity import DefaultAzureCredential`
`akvName = 'azurekeyvault-name'`
`kv_access_token = mssparkutils.credentials.getToken("keyvault")`
`refresh_token = tl.get_secret_with_token("https://keyvault","secret_name",kv_access_token)`
`refresh_token = tl.get_secret_with_token("https://keyvault","secret_name",kv_access_token)`
but when setting or putting a secret it returns an error:
`mssparkutils.credentials.putSecret(akvName, secret_name, secret_value)`
**Error:**
> Py4JJavaError: An error occurred while calling z:mssparkutils.credentials.putSecret. : java.util.NoSuchElementException: spark.arcadia.session.token at org.apache.spark.SparkConf.$anonfun$get$1(SparkConf.scala:266) at scala.Option.getOrElse(Option.scala:189) at org.apache.spark.SparkConf.get(SparkConf.scala:266) at com.microsoft.azure.synapse.tokenlibrary.TokenLibrary.$anonfun$getAccessTokenInternal$3(TokenLibrary.scala:271) at scala.util.Try$.apply(Try.scala:213) at com.microsoft.azure.synapse.tokenlibrary.TokenLibrary.getAccessTokenInternal(TokenLibrary.scala:270) at com.microsoft.azure.synapse.tokenlibrary.TokenLibrary.$anonfun$getAccessTokenInternal$4(TokenLibrary.scala:303) at scala.util.Try$.apply(Try.scala:213) at com.microsoft.azure.synapse.tokenlibrary.TokenLibrary.getAccessTokenInternal(TokenLibrary.scala:291) at com.microsoft.azure.synapse.tokenlibrary.TokenLibrary.getAccessTokenAsync(TokenLibrary.scala:216) at com.microsoft.azure.synapse.tokenlibrary.TokenLibrary.putAkvSecret(TokenLibrary.scala:815) at com.microsoft.azure.synapse.tokenlibrary.TokenLibrary$.putSecret(TokenLibrary.scala:1386) at mssparkutils.credentials$.putSecret(credentials.scala:138) at mssparkutils.credentials.putSecret(credentials.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357) at py4j.Gateway.invoke(Gateway.java:282) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:238) at java.lang.Thread.run(Thread.java:750)
​
Hi @Itsgoodas ,
Thankyou for using Microsoft Fabric Community and thanks for posting your question here.
I would be taking this forward to our internal team to understand if there is any deployment responsible for this error you are experiencing. However, meanwhile, I want you to make sure the following permissions are all set at your end. Kindly make sure :
Looking forward to your response. Thanks.
Hi @Itsgoodas ,
We haven’t heard from you on the last response and was just checking back to see if you can provide the details asked above. Please let us know if you have any further queries.
Hi @Itsgoodas ,
Just following up to check whether you can provide the details asked in the above comment. Do let us know if you have any further queries.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Fabric update to learn about new features.