我如何从控制器代码中从Azure键保险库中检索秘密
我创建了一个Azure密钥库,可以保存我的应用程序秘密。
我想从控制器代码中检索秘密。我的控制器代码基于ASP.NET核心。
从这里开始, https://learn.microsoft.com /en-us/dotnet/api/概述/azure/endentity-readme
我看到了一个示例要创建一个 secretclient
// Create a secret client using the DefaultAzureCredential
var client = new SecretClient(new Uri("https://myvault.vault.azure.net/"), new DefaultAzureCredential());
我的问题是因为我在服务端(在控制器端)上运行代码,如何在没有任何交互式身份验证的情况下创建DefaultazureCrecreCrecreCrecreCrecreCrecreCrecreCrecreCrecreCrecreCrecrecreCrecreCrecreCrecreCrecreCrecreCrecreCrecreCrecrecreCrecreCredential?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您在 defaultazurecrecrecredential 在服务中,您可以使用具有用户托管身份的应用程序,
DefaultazureCrecrecreCredential
将使用该帐户进行身份验证 是没有交互式模式的azure_client_id 环境可用于设置 ManagedIdentityClientId 除了通过代码设置它。当利用DefaultazureCrecreCredential时,这两种方法是相等的。您无需在代码中公开凭据,您可以使用此身份登录到接受Azure AD身份验证(包括密钥库)的任何服务。
您也可以参考此 ms-document 更多详细使用托管身份将密钥库连接到.NET中的Azure Web应用程序
According to Document referred by you under DefaultAzureCredential , In service side you can use the application with user Managed Identity,
DefaultAzureCredential
will authenticate with that account which is without interactive mode.The Azure_client_id environment variable can be used to set the ManagedIdentityClientId in addition to setting it via code. When utilising the DefaultAzureCredential, these two approaches are equal. Without having to expose credentials in your code, you may use this identity to log in to any service that accepts Azure AD authentication, including Key Vault.
You can also refer this MS-Document more in detail to use managed identity to connect Key Vault to an Azure web app in .NET