Jack Lebbos
Jack Lebbos

Reputation: 237

Azure keyvault client 1.0.0 initiate client

In azure Keyvault website link

I found this code:

KeyVaultClient kvc = new KeyVaultClient(credentials);
KeyBundle returnedKeyBundle = getKey(vaultUrl, keyName);
JsonWebKey jsonKey = returnedKeyBundle.key();

But how to get he client credentials is not explained, and all the old methods is not valid with the library version 1.0.0. I want to use application id and secret to authenticate, but how?

Upvotes: 0

Views: 267

Answers (1)

Peter Pan
Peter Pan

Reputation: 24148

Per my understanding, I think the code below is that you want if you had known how to register an application in Azure AD.

String clientId = "<client id of your application registed on Azure AD>";
String domain = "<your talnet id>";
String secret = "<client key of your application registed on Azure AD>";
String subscription = "<your subscription id>";
AzureTokenCredentials cred = new ApplicationTokenCredentials(clientId, domain, secret, AzureEnvironment.AZURE);
KeyVaultClient kvc = new KeyVaultClient(credentials);

Or follow the figure below to register an application in Azure AD on Azure portal, then to do the above.

enter image description here


Update: Please add the azure dependency as below

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure</artifactId>
    <version>1.1.0</version>
</dependency>

Upvotes: 1

Related Questions