Toto
Toto

Reputation: 139

Azure ARM templates : DocumentDB primaryMasterKey as OUTPUT

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}

Upvotes: 3

Views: 1404

Answers (1)

4c74356b41
4c74356b41

Reputation: 72171

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]"
}

Upvotes: 4

Related Questions