CosmosDB 触发函数的框架代码为:
[CosmosDBTrigger(
databaseName: "databaseName",
collectionName: "collectionName",
ConnectionStringSetting = "string",
LeaseCollectionName = "leases")]
ConnectionStringSetting
仅限于此处的应用设置。 我想去密钥保管库获取这个秘密。
该属性的注释表明有一种方法可以使用 CosmosDBOptions:
/// Optional. A string value indicating the app setting to use as the CosmosDB connection string, if different
/// than the one specified in the <see cref="CosmosDBOptions"/>.
但不清楚如何在 Azure 函数的上下文中使用该类。
这可能吗?
现在,该解决方案在 Azure 函数中可用
可以将所有密钥、机密和证书放入密钥保管库,并通过密钥值 URL(使用"管理标识"(进行访问。使用管理标识,无需在 Azure 函数配置中存储密钥保管库凭据。
Azure 中的密钥保管库机密具有管理标识的功能
CosmosDBOptions
是指可以在host.json
级别设置的配置。
目前无法从 Azure 密钥保管库设置连接字符串,但这是我们想要包含的一项功能。