2017-07-02 105 views
0

在蔚藍Keyvault網站linkAzure的keyvault客戶端1.0.0啓動客戶端

我發現這個代碼:

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

可是如何才能讓自己的客戶端憑證就不解釋了,所有的老方法是不在1.0.0版的庫中有效。 我想使用應用程序ID和密碼進行身份驗證,但是如何?

回答

1

根據我的理解,我認爲下面的代碼是你想要的,如果你已經知道如何在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); 

或按照下圖在Azure門戶上註冊Azure AD中的應用程序,然後執行上述操作。

enter image description here


更新:請添加azure依賴如下

<dependency> 
    <groupId>com.microsoft.azure</groupId> 
    <artifactId>azure</artifactId> 
    <version>1.1.0</version> 
</dependency> 
在蔚藍1.0.0 ApplicationTokenCredentials
+0

不存在了 –

+0

com.microsoft.azure 蔚藍-keyvault 1.0.0

+0

@JackLebbos我更新了我的回覆,請添加'azure'依賴項。 –