Skip to content

Commit 1435468

Browse files
authored
Revert "Only add an explicit dependency on an existing resource when the deployments engine will use the GET response" (#15524)
Reverts #15447 to address #15513 There is a subtle bug in the way `dependsOn` is generated when a non-copy resource (_r_) depends on a copy resource (_parent_) which depends on a copy resource (_grandparent_) when _parent_ is not included in the calculated dependency graph. Note that even with this reversion, this scenario is still broken for non-symbolic name templates, but this is not unique to v0.31. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/Azure/bicep/pull/15524)
1 parent 688cd8f commit 1435468

File tree

26 files changed

+175
-515
lines changed

26 files changed

+175
-515
lines changed

src/Bicep.Core.IntegrationTests/ExistingResourceTests.cs

Lines changed: 0 additions & 401 deletions
This file was deleted.

src/Bicep.Core.IntegrationTests/ScenarioTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5065,7 +5065,7 @@ public void Test_Issue10343()
50655065
"));
50665066

50675067
var evaluated = TemplateEvaluator.Evaluate(result.Template);
5068-
evaluated.Should().HaveValueAtPath("resources.foo3.dependsOn", new JArray("foo1"));
5068+
evaluated.Should().HaveValueAtPath("resources.foo3.dependsOn", new JArray("foo2"));
50695069
}
50705070

50715071
// https://github.com/Azure/bicep/issues/11292
@@ -6315,7 +6315,7 @@ public void Test_Issue13596(bool enableSymbolicNameCodegen)
63156315

63166316
if (enableSymbolicNameCodegen)
63176317
{
6318-
result.Template.Should().HaveJsonAtPath("$.resources.secret.dependsOn", """["mod"]""");
6318+
result.Template.Should().HaveJsonAtPath("$.resources.secret.dependsOn", """["sa"]""");
63196319
}
63206320
else
63216321
{

src/Bicep.Core.Samples/Files/baselines/Modules_CRLF/main.symbolicnames.json

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "dev",
9-
"templateHash": "14846102413726496336"
9+
"templateHash": "12632249060210513106"
1010
}
1111
},
1212
"parameters": {
@@ -1851,7 +1851,10 @@
18511851
}
18521852
}
18531853
}
1854-
}
1854+
},
1855+
"dependsOn": [
1856+
"kv"
1857+
]
18551858
},
18561859
"secureModule2": {
18571860
"type": "Microsoft.Resources/deployments",
@@ -1909,7 +1912,10 @@
19091912
}
19101913
}
19111914
}
1912-
}
1915+
},
1916+
"dependsOn": [
1917+
"scopedKv"
1918+
]
19131919
},
19141920
"secureModuleLooped": {
19151921
"copy": {
@@ -1971,7 +1977,11 @@
19711977
}
19721978
}
19731979
}
1974-
}
1980+
},
1981+
"dependsOn": [
1982+
"[format('loopedKv[{0}]', copyIndex())]",
1983+
"[format('loopedKv[{0}]', copyIndex())]"
1984+
]
19751985
},
19761986
"secureModuleCondition": {
19771987
"type": "Microsoft.Resources/deployments",
@@ -2014,7 +2024,10 @@
20142024
}
20152025
}
20162026
}
2017-
}
2027+
},
2028+
"dependsOn": [
2029+
"kv"
2030+
]
20182031
},
20192032
"withSpace": {
20202033
"type": "Microsoft.Resources/deployments",

src/Bicep.Core.Samples/Files/baselines/NestedResources_LF/main.symbolicnames.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "dev",
9-
"templateHash": "236868819280717113"
9+
"templateHash": "16972434704035043060"
1010
}
1111
},
1212
"parameters": {
@@ -71,13 +71,19 @@
7171
"properties": {
7272
"size": "[reference('existingParent').size]",
7373
"style": "[reference('existingParent::existingChild').style]"
74-
}
74+
},
75+
"dependsOn": [
76+
"existingParent::existingChild"
77+
]
7578
},
7679
"existingParent::existingChild": {
7780
"existing": true,
7881
"type": "My.Rp/parentType/childType",
7982
"apiVersion": "2020-12-01",
80-
"name": "[format('{0}/{1}', 'existingParent', 'existingChild')]"
83+
"name": "[format('{0}/{1}', 'existingParent', 'existingChild')]",
84+
"dependsOn": [
85+
"existingParent"
86+
]
8187
},
8288
"conditionParent::conditionChild::conditionGrandchild": {
8389
"condition": "[and(and(parameters('createParent'), parameters('createChild')), parameters('createGrandchild'))]",

src/Bicep.Core.Samples/Files/baselines/Resources_CRLF/main.symbolicnames.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "dev",
9-
"templateHash": "15062227467638827925"
9+
"templateHash": "12953345672979673276"
1010
}
1111
},
1212
"parameters": {
@@ -665,7 +665,10 @@
665665
"p3_child1": {
666666
"type": "Microsoft.Rp1/resource1/child1",
667667
"apiVersion": "2020-06-01",
668-
"name": "[format('{0}/{1}', 'res1', 'child1')]"
668+
"name": "[format('{0}/{1}', 'res1', 'child1')]",
669+
"dependsOn": [
670+
"p3_res1"
671+
]
669672
},
670673
"p4_res1": {
671674
"existing": true,
@@ -679,7 +682,10 @@
679682
"type": "Microsoft.Rp1/resource1/child1",
680683
"apiVersion": "2020-06-01",
681684
"scope": "/",
682-
"name": "[format('{0}/{1}', 'res1', 'child1')]"
685+
"name": "[format('{0}/{1}', 'res1', 'child1')]",
686+
"dependsOn": [
687+
"p4_res1"
688+
]
683689
},
684690
"sqlServer": {
685691
"type": "Microsoft.Sql/servers",

src/Bicep.Core.Samples/Files/user_submitted/101/api-management-modular/NameValues.symbolicnames.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "dev",
9-
"templateHash": "14248540637091011874"
9+
"templateHash": "11528852364160566097"
1010
}
1111
},
1212
"parameters": {
@@ -56,7 +56,10 @@
5656
"secret": "[variables('apimNameValueSet')[copyIndex()].isSecret]",
5757
"value": "[variables('apimNameValueSet')[copyIndex()].value]",
5858
"tags": "[variables('apimNameValueSet')[copyIndex()].tags]"
59-
}
59+
},
60+
"dependsOn": [
61+
"parentAPIM"
62+
]
6063
}
6164
},
6265
"outputs": {

src/Bicep.Core.Samples/Files/user_submitted/101/api-management-modular/groups.symbolicnames.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "dev",
9-
"templateHash": "6816770503491912011"
9+
"templateHash": "403029788224868668"
1010
}
1111
},
1212
"parameters": {
@@ -47,7 +47,10 @@
4747
"properties": {
4848
"displayName": "[variables('groupsSet')[copyIndex()].groupDisplayName]",
4949
"description": "[variables('groupsSet')[copyIndex()].groupDescription]"
50-
}
50+
},
51+
"dependsOn": [
52+
"parentAPIM"
53+
]
5154
}
5255
},
5356
"outputs": {

src/Bicep.Core.Samples/Files/user_submitted/101/api-management-modular/main.symbolicnames.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "dev",
9-
"templateHash": "2208926443863165998"
9+
"templateHash": "13726378283629199613"
1010
}
1111
},
1212
"parameters": {
@@ -163,7 +163,7 @@
163163
"_generator": {
164164
"name": "bicep",
165165
"version": "dev",
166-
"templateHash": "6816770503491912011"
166+
"templateHash": "403029788224868668"
167167
}
168168
},
169169
"parameters": {
@@ -204,7 +204,10 @@
204204
"properties": {
205205
"displayName": "[variables('groupsSet')[copyIndex()].groupDisplayName]",
206206
"description": "[variables('groupsSet')[copyIndex()].groupDescription]"
207-
}
207+
},
208+
"dependsOn": [
209+
"parentAPIM"
210+
]
208211
}
209212
},
210213
"outputs": {
@@ -248,7 +251,7 @@
248251
"_generator": {
249252
"name": "bicep",
250253
"version": "dev",
251-
"templateHash": "16793550498477002119"
254+
"templateHash": "8034218730798252475"
252255
}
253256
},
254257
"parameters": {
@@ -298,7 +301,10 @@
298301
"email": "[variables('usersSet')[copyIndex()].email]",
299302
"state": "[variables('usersSet')[copyIndex()].state]",
300303
"note": "[variables('usersSet')[copyIndex()].notes]"
301-
}
304+
},
305+
"dependsOn": [
306+
"parentAPIM"
307+
]
302308
}
303309
}
304310
}
@@ -330,7 +336,7 @@
330336
"_generator": {
331337
"name": "bicep",
332338
"version": "dev",
333-
"templateHash": "14248540637091011874"
339+
"templateHash": "11528852364160566097"
334340
}
335341
},
336342
"parameters": {
@@ -380,7 +386,10 @@
380386
"secret": "[variables('apimNameValueSet')[copyIndex()].isSecret]",
381387
"value": "[variables('apimNameValueSet')[copyIndex()].value]",
382388
"tags": "[variables('apimNameValueSet')[copyIndex()].tags]"
383-
}
389+
},
390+
"dependsOn": [
391+
"parentAPIM"
392+
]
384393
}
385394
},
386395
"outputs": {

src/Bicep.Core.Samples/Files/user_submitted/101/api-management-modular/users.symbolicnames.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "dev",
9-
"templateHash": "16793550498477002119"
9+
"templateHash": "8034218730798252475"
1010
}
1111
},
1212
"parameters": {
@@ -56,7 +56,10 @@
5656
"email": "[variables('usersSet')[copyIndex()].email]",
5757
"state": "[variables('usersSet')[copyIndex()].state]",
5858
"note": "[variables('usersSet')[copyIndex()].notes]"
59-
}
59+
},
60+
"dependsOn": [
61+
"parentAPIM"
62+
]
6063
}
6164
}
6265
}

src/Bicep.Core.Samples/Files/user_submitted/101/azure-bastion/main.symbolicnames.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "dev",
9-
"templateHash": "12715898051173612753"
9+
"templateHash": "5898567106534730923"
1010
}
1111
},
1212
"parameters": {
@@ -149,7 +149,10 @@
149149
]
150150
}
151151
}
152-
}
152+
},
153+
"dependsOn": [
154+
"existingVirtualNetwork"
155+
]
153156
},
154157
"bastionHost": {
155158
"type": "Microsoft.Network/bastionHosts",

0 commit comments

Comments
 (0)