Azure ARM templates : DocumentDB primaryMasterKey as OUTPUT

一曲冷凌霜 提交于 2021-01-27 13:46:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!