Azure Keyvault客户端1.0.0启动客户端 [英] Azure keyvault client 1.0.0 initiate client
问题描述
在azure Keyvault网站链接 >
我找到了以下代码:
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>
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?
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.
Update: Please add the azure
dependency as below
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
<version>1.1.0</version>
</dependency>
这篇关于Azure Keyvault客户端1.0.0启动客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!