问题
In a Azure ARM templates I'm having some problems trying to extract in the OUTPUT section the 'primaryMasterKey' of a DocumentDB created in the RESOURCES section.
The deploy reports this error :
The template output 'documentDbPrimaryMasterKey' is not valid: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.. (Code: DeploymentOutputEvaluationFailed)
The definition of that OUTPUT is :
"documentDbPrimaryMasterKey": {
"type": "object",
"value": "[listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('documentDb').name), providers('Microsoft.DocumentDB','databaseAccounts').apiVersions[0]).primaryMasterKey]"
}
Here my template https://github.com/toto-castaldi/azure-templates/blob/master/documentdb/template.json
It is strange beacuse the result of "listKeys" is a correct JSON like
{"primaryMasterKey":"XXXX","secondaryMasterKey":"XXX","primaryReadonlyMasterKey":"XXX","secondaryReadonlyMasterKey":"XXXX}
回答1:
Well, you obviously want a string, not an object :)
"documentDbPrimaryMasterKey": {
"type": "String", # <<< STRING
"value": "[listKeys(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('documentDb').name), providers('Microsoft.DocumentDB','databaseAccounts').apiVersions[0]).primaryMasterKey]"
}
来源:https://stackoverflow.com/questions/42486845/azure-arm-templates-documentdb-primarymasterkey-as-output