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

Commit 747ed9e

Browse files
rhollambyRobert HollambyRupengLiu
authored
Sequence contains no elements error fix (#475) (#497)
Co-authored-by: Robert Hollamby <robert@hollamb.net> Co-authored-by: RupengLiu <rliu1211@terpmail.umd.edu>
1 parent 453c5d6 commit 747ed9e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,21 @@ public async Task<Template> GenerateAPITagsARMTemplateAsync(string singleApiName
128128
{
129129
templateResources.AddRange(await GenerateSingleAPITagResourceAsync(apiName, exc, dependsOn));
130130

131-
// Extract the tag name from the last resource
132-
string[] lastTagName = templateResources.Last().name.Replace("')]", "").Split('/');
133-
if (lastTagName.Length > 3)
134-
{
135-
// Operations tag
136-
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/apis/operations/tags', parameters('{ParameterNames.ApimServiceName}'), '{apiName}', '{lastTagName[2]}', '{lastTagName[3]}')]" };
137-
}
138-
else
131+
if (templateResources.Count > 0)
139132
{
140-
// API tag
141-
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/apis/tags', parameters('{ParameterNames.ApimServiceName}'), '{apiName}', '{lastTagName[2]}')]" };
133+
134+
// Extract the tag name from the last resource
135+
string[] lastTagName = templateResources.Last().name.Replace("')]", "").Split('/');
136+
if (lastTagName.Length > 3)
137+
{
138+
// Operations tag
139+
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/apis/operations/tags', parameters('{ParameterNames.ApimServiceName}'), '{apiName}', '{lastTagName[2]}', '{lastTagName[3]}')]" };
140+
}
141+
else
142+
{
143+
// API tag
144+
dependsOn = new string[] { $"[resourceId('Microsoft.ApiManagement/service/apis/tags', parameters('{ParameterNames.ApimServiceName}'), '{apiName}', '{lastTagName[2]}')]" };
145+
}
142146
}
143147
}
144148
}

0 commit comments

Comments
 (0)