@@ -99,17 +99,14 @@ async Task<List<ProductApiTemplateResource>> GenerateMultipleApisTemplateAsync(L
9999 {
100100 this . logger . LogInformation ( "Processing {0} api-names..." , multipleApiNames . Count ) ;
101101
102- string [ ] dependsOn = Array . Empty < string > ( ) ;
103102 var templateResources = new List < ProductApiTemplateResource > ( ) ;
104103 foreach ( string apiName in multipleApiNames )
105104 {
106- var productApiTemplateResources = await this . GenerateProductApiTemplateResourcesAsync ( apiName , extractorParameters , dependsOn ) ;
105+ var productApiTemplateResources = await this . GenerateProductApiTemplateResourcesAsync ( apiName , extractorParameters , null ) ;
107106
108107 if ( ! productApiTemplateResources . IsNullOrEmpty ( ) )
109108 {
110109 templateResources . AddRange ( productApiTemplateResources ) ;
111- string apiProductName = templateResources . Last ( ) . Name . Split ( '/' , 3 ) [ 1 ] ;
112- dependsOn = new string [ ] { $ "[resourceId('Microsoft.ApiManagement/service/products/apis', parameters('{ ParameterNames . ApimServiceName } '), '{ apiProductName } ', '{ apiName } ')]" } ;
113110 }
114111 }
115112
@@ -119,7 +116,7 @@ async Task<List<ProductApiTemplateResource>> GenerateMultipleApisTemplateAsync(L
119116 async Task < List < ProductApiTemplateResource > > GenerateProductApiTemplateResourcesAsync (
120117 string apiName ,
121118 ExtractorParameters extractorParameters ,
122- string [ ] dependsOn )
119+ string [ ] dependsOn = null )
123120 {
124121 var productApiResources = new List < ProductApiTemplateResource > ( ) ;
125122 this . logger . LogInformation ( "Extracting products from {0} API:" , apiName ) ;
@@ -128,7 +125,6 @@ async Task<List<ProductApiTemplateResource>> GenerateProductApiTemplateResources
128125 {
129126 var productApis = await this . productsClient . GetAllLinkedToApiAsync ( apiName , extractorParameters ) ;
130127
131- string lastProductAPIName = null ;
132128 foreach ( var productApi in productApis )
133129 {
134130 this . logger . LogInformation ( "'{0}' Product association found" , productApi . OriginalName ) ;
@@ -138,11 +134,13 @@ async Task<List<ProductApiTemplateResource>> GenerateProductApiTemplateResources
138134 productApi . Name = $ "[concat(parameters('{ ParameterNames . ApimServiceName } '), '/{ productApi . NewName } /{ apiName } ')]";
139135 productApi . ApiVersion = GlobalConstants . ApiVersion ;
140136 productApi . Scale = null ;
141- productApi . DependsOn = lastProductAPIName != null ? new string [ ] { lastProductAPIName } : dependsOn ;
142-
137+ if ( ! dependsOn . IsNullOrEmpty ( ) )
138+ {
139+ productApi . DependsOn = dependsOn ;
140+ }
141+
143142 productApiResources . Add ( productApi ) ;
144143
145- lastProductAPIName = $ "[resourceId('Microsoft.ApiManagement/service/products/apis', parameters('{ ParameterNames . ApimServiceName } '), '{ productApi . NewName } ', '{ apiName } ')]";
146144 }
147145 }
148146 catch ( Exception ex )
0 commit comments