2

I deploy 30 SQL databases via copyIndex() as sub deployments of the main deployment, I want to be able to reference the outputs of the dynamic deployments when kicking off another deployment. Once all the databases are deployed, I want to then all Azure Monitor metric rules to the DBs, and need their resourceIds (the Output of the db deploy).

The answer here sounds exactly like what I'm trying to do, and I understand that each deployment is chained to have the output of the previous deploy. But then if I want to use the chained up "state" output, is it the very last element in the array that has the full chain? If so is the best way to reference that to just build up the name of the deployment and append on the length of the copyIndex array?

reference(concat('reference', length(variables('types'))).outputs.state.value

As so?

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
David C
  • 664
  • 1
  • 8
  • 21

1 Answers1

1

yes, you basically need to construct a name that is the name of the deployment:

referenceX

where X is the number of the last deployment, you can use length() function for that exactly as you suggest it.

the above will work only if you gather the output from all the intermediate steps, obviously

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Yea that makes sense now, I will definitely get looked at weirdly for creating this PR... It will also slow down the deployment quite a bit as I assume it will become synchronous based on the chained dependency. – David C Sep 13 '19 at 17:36
  • I want to do the same, but with my limited experience with ARM templates I dont fully grok your answer here. Could you elaborate in my question here if possible? Thanx https://stackoverflow.com/questions/60394678/how-to-get-resourceid-as-output-for-vm-when-using-copyindex – Anders Rask Feb 25 '20 at 12:29