Reputation: 83
I am trying to use app with certificate for authentication in KustoConnectionStringBuilder, the certificate is saved in a KeyVault, as I found from the examples in github is required to download the PEM file as shown in the code below:
filename = "path to a PEM certificate"
with open(filename, "r") as pem_file:
PEM = pem_file.read()
thumbprint = "certificate's thumbprint"
kcsb = KustoConnectionStringBuilder.with_aad_application_certificate_authentication(cluster, client_id, PEM, thumbprint, authority_id)
Could someone point me in how to properly retrieve the certificate from the KeyVault in Synapse, I tried using DefaultAzureCredentials and looks is not supported in Synapse, is there any way to retrieve the cer file using linked service of the KeyVault?
Upvotes: 0
Views: 316
Reputation: 5317
DefaultAzureCredentials and looks are not supported in Synapse. Is there any way to retrieve the .cer file using a linked service of the KeyVault?
You can follow the procedure below to retrieve a certificate from the key vault:
TenantId
, ClientId
, and Secret
values. Add the Key Vault Administrator role in the key vault to the service principal by selecting IAM and clicking on Add and select Add role assignment
.user or group
option and click on the select member
option. Select the SPN and click on the Review + Assign
option.from azure.identity import ClientSecretCredential
from azure.keyvault.certificates import CertificateClient
credential = ClientSecretCredential("<tenant_id>", "<client_id>", "<client_secret>")
certificate_client = CertificateClient(vault_url="https://<keyVaultName>.vault.azure.net/", credential=credential)
certificate = certificate_client.get_certificate("<certificateName>")
print(certificate.name)
print(certificate.properties.version)
print(certificate.policy.issuer_name)
This will retrieve the details successfully, as shown below:
For more information, you can refer to this.
Upvotes: 0