azure-resource-manager - ARM 访问 Azure Cosmos DB 中的 Gremlin 终结点
问题描述
是否可以使用 ARM 访问 Cosmos 数据库的 Graph / Gremlin 端点,以便例如将其设置为应用程序设置?
您可以使用以下语法访问 ARM 中的 Document / SQL 端点:
[reference('Microsoft.DocumentDb/databaseAccounts/mydb').documentEndpoint]
但是在 resources.azure.com 中我找不到 Gremlin 端点的等效项,这会导致问题,因为 Azure 中的 Graph / Gremlin 数据库现在至少有两种端点格式:
mydb.gremlin.cosmosdb.azure.com (older format)
mydb.graphs.azure.com (newer format)
我已经部署了一个跨环境使用混合名称格式的系统,目前必须通过将名称的不同格式作为参数传递来解决它,但这显然有点脆弱,需要我有先验知识。
解决方案
是否可以使用 ARM 访问 Cosmos 数据库的 Graph / Gremlin 端点
简短的回答是肯定的。请尝试使用以下代码进行操作,reference(resourceId('Microsoft.DocumentDB/databaseAccounts', 'gremlinAccount')).gremlinEndpoint
然后我们可以获得
"gremlinEndpoint": "https://xxxx.gremlin.cosmosdb.azure.com:443/",
以下是演示代码:
"variables": {
"graphDbAccount": {
"name": "gremlinAccount"
},
"resourceId": "[resourceId('Microsoft.DocumentDB/databaseAccounts', variables('graphDbAccount').name)]"
}
"outputs": {
"gremlinEndpoint": {
"type": "string",
"value": "[reference(variables('resourceId')).gremlinEndpoint]"
}
}