1

I wonder if there is a way to get a resourceId with name that matches a regular expression in another subscription. The reason is that during deployment a random postfix is generated and appended to resource name, so resource name is not known beforehand. I know the resourceId() function could give you the resource Id if the resource name is known.

Yituo
  • 1,458
  • 4
  • 17
  • 26
  • When using `resourceId()`, is the resource being deployed as part of the same template, or has it already been deployed beforehand as a completely separate deployment? – jarrad_obrien Sep 30 '19 at 04:23
  • The resources have been deployed through a separate deployment in a different resource group. @jarrad_obrien – Yituo Sep 30 '19 at 04:25
  • 1
    How come the names of the existing resources can't be used as parameters in the new template? – jarrad_obrien Sep 30 '19 at 05:34
  • Its because the resource name are generated during deployment, and not known beforehand. I think there are ways to get around the question I asked, its just not as clean. @jarrar_obrien – Yituo Sep 30 '19 at 17:31
  • I mean that in the second template, how come you can't create a parameter such as `namesOfExistingResources` and populate it with the existing resources? e.g. `namesOfExistingResources: ['myResource2834', 'myResource7482']` – jarrad_obrien Sep 30 '19 at 23:01
  • @Jarrad_obrien. I am trying to minimize these hard coded inputs in the deployment pipeline. Thank you for your suggestion, its a clean way to get around the question I asked. But listing with regular expression would still be a nice feature to have, especially for large scale deployment, could help avoid many human errors~ – Yituo Oct 01 '19 at 17:32

1 Answers1

0

You can achieve this by using the output of the previous template as input to the new template:

Azure ARM templates - using the output of other deployments

Here is how to achieve this in Azure DevOps:

How do I use ARM 'outputs' values another release task?

AmanGarg-MSFT
  • 1,123
  • 6
  • 10