Azure的keyvault客户端1.0.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和密码进行身份验证,但是如何?
答
根据我的理解,我认为下面的代码是你想要的,如果你已经知道如何在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'依赖项。 –