@@ -48,6 +48,10 @@ function generateTemplate(input) {
4848 return `[resourceId('Microsoft.ApiManagement/service/apis', '${ serviceName } ', '${ api . fullName } ')]` ;
4949 }
5050
51+ function resourceIdOperation ( serviceName , api , operation ) {
52+ return `[resourceId('Microsoft.ApiManagement/service/apis/operations', '${ serviceName } ', '${ api . fullName } ', '${ operation . name } ')]` ;
53+ }
54+
5155 function resourceIdProduct ( serviceName , product ) {
5256 return `[resourceId('Microsoft.ApiManagement/service/products', '${ serviceName } ', '${ product . fullName } ')]` ;
5357 }
@@ -69,6 +73,8 @@ function generateTemplate(input) {
6973 for ( const environment of input . environments ) {
7074 const { serviceName } = environment . configuration ;
7175
76+ let previousApiId = null ;
77+
7278 for ( const api of environment . apis ) {
7379 const apiResourceId = resourceIdApi ( serviceName , api ) ;
7480
@@ -83,6 +89,7 @@ function generateTemplate(input) {
8389 protocols : [ "https" ] ,
8490 isCurrent : true
8591 } ,
92+ dependsOn : previousApiId == null ? [ ] : [ previousApiId ] ,
8693 resources : toArray ( api . policies , {
8794 type : "policies" ,
8895 name : "policy" ,
@@ -108,11 +115,16 @@ function generateTemplate(input) {
108115 }
109116 }
110117
118+ let previousOperationId = null ;
119+
111120 for ( const operation of api . operations ) {
112121 addResource ( {
113122 type : "Microsoft.ApiManagement/service/apis/operations" ,
114123 name : `${ serviceName } /${ operation . fullName } ` ,
115- dependsOn : [ apiResourceId ] ,
124+ dependsOn :
125+ previousOperationId == null
126+ ? [ apiResourceId ]
127+ : [ apiResourceId , previousOperationId ] ,
116128 properties : {
117129 displayName : operation . fullDisplayName ,
118130 method : operation . method ,
@@ -133,7 +145,10 @@ function generateTemplate(input) {
133145 }
134146 } )
135147 } ) ;
148+ previousOperationId = resourceIdOperation ( serviceName , api , operation ) ;
136149 }
150+
151+ previousApiId = apiResourceId ;
137152 }
138153
139154 for ( const product of environment . products ) {
0 commit comments