'How to get the KeyVault name in the notebook from the keyvault link in Synapse?
How to get the KeyVault name in the notebook from the keyvault link in Synapse?
I need the KeyVault name to pass to the TokenLibrary.
TokenLibrary.getSecret(keyVaultName,"MyConnectionString", "AzureKeyVaultLink")
Solution 1:[1]
Please make sure to enable managed service identity and add keyvault secrets and also add linked service to azure synapse
Go Azure key Vault in my case keyvam
is KeyVault name.
Syntax:
connection_string = TokenLibrary.getSecret("mykeyvault", "ConnectionString")
you can use linked service as shown in the below reference.
connection_string = TokenLibrary.getSecret("mykeyvault", "ConnectionString", "AzureKeyVaultLinkedServiceName")
Sample example:
import sys
from pyspark.sql import SparkSession
sc = SparkSession.builder.getOrCreate()
token_library = sc._jvm.com.microsoft.azure.synapse.tokenlibrary.TokenLibrary
connection_string = token_library.getSecret('keyvam','vamsi')
print(connection_string)
Reference:
https://dzone.com/articles/securely-access-azure-sql-database-from-azure-syna
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | BhanunagasaiVamsi-MT |