使用 Azure Active Directory 访问 Service Fabric 应用程序的 Key Vault

Access Key Vault for a Service Fabric application using Azure Active Directory

我有一个在 Service Fabric(SF) 集群中运行的应用程序,我不想从它访问 Key Vault。

该集群托管了许多应用程序,我想为我的应用程序授予对 Key Vault 的访问权限,而不授予对其他应用程序的访问权限。默认情况下,应用程序在与 SF 集群相同的用户下运行,但每个应用程序都有自己唯一的名称,我的名称为 fabric:/application1.

我的问题是,是否可以为 fabric:/application1 创建一个 Active Directory 应用程序帐户并授予对密钥保管库的访问权限?

我知道可以在 SF 清单中使用 RunAs 选项,但这需要我在 manifest/source 代码中存储加密密码,我想尽可能避免这种情况。

据我所知,

获得这种灵活性的唯一方法是使用 ClientID & SecretService Principal certificates,并且每个应用程序管理自己的凭据。

Service Principal Certificate 已经集成到 AD,但不需要应用程序、用户或主机是域的一部分,唯一的要求是设置一个用户在 AD 上授予对 Keyvault 的权限。

还有其他使用 AD 集成的解决方案,例如 Managed identities for Azure resources(以前:托管服务身份),但我不确定您是否能够像您描述的那样限制每个应用程序的访问,因为 MI 将其添加为节点中的服务,因此从技术上讲其他应用程序也可以访问,值得尝试验证是否可以限制它。

如果您想尝试这种方法,可以使用 with Microsoft.Azure.Services.AppAuthentication for implicit authentication of the services running in your cluster, where the nodes are setup with Managed Identities extension like described here

某事 link 这个:

当您使用 Microsoft.Azure.Services.AppAuthentication 时,第 2 步将由库处理,您不必对密钥保管库身份验证逻辑添加太多更改。

When you run your code on an Azure App Service or an Azure VM with a managed identity enabled, the library automatically uses the managed identity. No code changes are required.

以下 docs 描述了可用于 KeyVault 身份验证的其他选项。

PS:我已经使用客户端机密和证书完成了其他 KeyVault 集成,它们足够安全,使用证书,您可以将其存储在托管存储或应用程序中,我仅在以下情况下推荐 MI是您的解决方案的要求。