根據我的理解,我認爲下面的代碼是你想要的,如果你已經知道如何在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中的應用程序,然後執行上述操作。
更新:請添加azure
依賴如下
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
<version>1.1.0</version>
</dependency>
在蔚藍1.0.0 ApplicationTokenCredentials
不存在了 –
@JackLebbos我更新了我的回覆,請添加'azure'依賴項。 –