从 Azure 函数配置中删除机密

Removing Secrets from Azure Function Config

像开始时的大多数 Azure Functions 一样,我们有一个连接到关联存储帐户的连接字符串,其中包括像这样的帐户密钥

DefaultEndpointsProtocol=https;AccountName=ourstorageAccount;EndpointSuffix=core.windows.net;AccountKey=WQfbn+VBhaY1fi/l0eRBzvAvngiCiOwPmx/==

我们显然想要删除那个 AccountKey。我曾希望我们可以使用 ManagedIdentity 和 'Contributor' 角色,但我正在阅读的内容告诉我您不能使用 Managed Identity 访问存储帐户中的 Tables只有 Blob.

我知道我们可以将整个连接字符串移动到 KeyVault,但如果我们想轮换密钥,那只会成为 Azure 管理问题。

有没有人成功地控制了对 Azure Table 具有托管身份的存储的访问?

如果不是,最好允许简单轮换键的下一个最佳方法是什么?

Has anyone successfully controlled access to Azure Table Storage with Managed Identities?

肯定是无法通过MSI访问azure table存储(managed identity,本质上是azure ad中的service principal),当使用MSI访问一些azure资源时,本质上是使用azure ad client credential flow获取token,然后使用token访问资源。

但是,azure blob 和队列存储仅支持 azure ad auth,table 存储目前不支持它,请参阅 - Authorize access to blobs and queues using Azure Active Directory

If not what is the next best approach that preferably allows for simple rotation of keys?

您可以使用 azure 函数来执行此操作,请遵循此文档 - Automate the rotation of a secret for resources with two sets of authentication credentials,我认为它完全满足您的要求,本教程使用触发的函数轮换存储在 Azure Key Vault 中的 Azure 存储帐户密钥作为机密通过 Azure 事件网格通知。