我不确定您到底想要什么,但我们使用 Azure Function 作为 arm 模板的一部分来配置 cosmosDb。这是它的工作原理:
"uri": "[concat('https://functionUrl?param1=', parameters('cosmosName'), '¶m2=', listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('cosmosName')), '2016-03-31').primaryMasterKey, '&code=', parameters('functionKey'))]"
这将调用 Azure Function 并为其提供 cosmosDb 名称和密钥,您可以在 Azure Function 中使用它来连接到 cosmosDb 并对其进行配置。唯一需要注意的是您的函数应该返回空模板(或不为空,只能由引擎解析)。
var template = @"{'$schema': 'https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#', 'contentVersion': '1.0.0.0', 'parameters': {}, 'variables': {}, 'resources': []}";
HttpResponseMessage myResponse = req.CreateResponse(HttpStatusCode.OK);
myResponse.Content = new StringContent(template, System.Text.Encoding.UTF8, "application/json");
return myResponse;