Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Itsgoodas
New Member

Writing / updating secrets to azure key vault from fabric

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)

​

3 REPLIES 3
v-nikhilan-msft
Community Support
Community Support

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 :

  • The Synapse notebook managed service identity has been granted Secrets permission to the Azure Key Vault. Check Enable Azure RBAC permissions on Key Vault for more details on how to do that.
  • Active directory user id has blob contributor role in the storage account.

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.

Helpful resources

Announcements
Expanding the Synapse Forums

New forum boards available in Synapse

Ask questions in Data Engineering, Data Science, Data Warehouse and General Discussion.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayFBCUpdateCarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

Top Kudoed Authors