Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 430ee12

Browse files
jobinpapjobin-semexRupengLiu
authored
Check list size before calling Last() (#486)
Co-authored-by: Pascal Jobin <pjobin@semex.com> Co-authored-by: RupengLiu <rliu1211@terpmail.umd.edu>
1 parent 4c4f9a1 commit 430ee12

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/APIM_ARMTemplate/apimtemplate/Extractor/EntityExtractors/ProductAPIExtractor.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,12 @@ public async Task<Template> GenerateAPIProductsARMTemplateAsync(string singleApi
104104
{
105105
string apiName = ((JValue)oApi["name"]).Value.ToString();
106106
templateResources.AddRange(await GenerateSingleProductAPIResourceAsync(apiName, exc, dependsOn));
107-
string apiProductName = templateResources.Last().name.Split('/', 3)[1];
108-
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/products/apis', parameters('{ParameterNames.ApimServiceName}'), '{apiProductName}', '{apiName}')]" };
107+
108+
if (templateResources.Count > 0)
109+
{
110+
string apiProductName = templateResources.Last().name.Split('/', 3)[1];
111+
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/products/apis', parameters('{ParameterNames.ApimServiceName}'), '{apiProductName}', '{apiName}')]" };
112+
}
109113
}
110114
}
111115
armTemplate.resources = templateResources.ToArray();

0 commit comments

Comments
 (0)