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

Commit 102be9b

Browse files
DSpiritWendelin NieslRupengLiu
authored
Remove property extraction limit of 100 (#482)
* #456 Remove property extraction limit * Remove debugging helper Co-authored-by: Wendelin Niesl <Wendelin.Niesl@plan-b-gmbh.com> Co-authored-by: RupengLiu <rliu1211@terpmail.umd.edu>
1 parent eb68e3f commit 102be9b

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,12 @@ public async Task<Template> CreateMasterTemplateParameterValues(List<string> api
471471
{
472472
Dictionary<string, string> namedValues = new Dictionary<string, string>();
473473
PropertyExtractor pExc = new PropertyExtractor();
474-
string properties = await pExc.GetPropertiesAsync(exc.sourceApimName, exc.resourceGroup);
475-
JObject oProperties = JObject.Parse(properties);
474+
string[] properties = await pExc.GetPropertiesAsync(exc.sourceApimName, exc.resourceGroup);
476475

477-
foreach (var extractedProperty in oProperties["value"])
476+
foreach (var extractedProperty in properties)
478477
{
479-
string propertyName = ((JValue)extractedProperty["name"]).Value.ToString();
478+
JToken oProperty = JObject.Parse(extractedProperty);
479+
string propertyName = ((JValue)oProperty["name"]).Value.ToString();
480480
string fullPropertyResource = await pExc.GetPropertyDetailsAsync(exc.sourceApimName, exc.resourceGroup, propertyName);
481481
PropertyTemplateResource propertyTemplateResource = JsonConvert.DeserializeObject<PropertyTemplateResource>(fullPropertyResource);
482482
string propertyValue = propertyTemplateResource.properties.value;

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

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,38 @@
44
using System.Collections.Generic;
55
using Newtonsoft.Json;
66
using Newtonsoft.Json.Linq;
7+
using System.Linq;
78

89
namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extract
910
{
1011
public class PropertyExtractor : EntityExtractor
1112
{
12-
public async Task<string> GetPropertiesAsync(string ApiManagementName, string ResourceGroupName)
13+
public async Task<string[]> GetPropertiesAsync(string ApiManagementName, string ResourceGroupName)
1314
{
14-
(string azToken, string azSubId) = await auth.GetAccessToken();
15+
JObject oProperty = new JObject();
16+
int numOfProperties = 0;
17+
List<string> propertyObjs = new List<string>();
18+
do
19+
{
20+
(string azToken, string azSubId) = await auth.GetAccessToken();
1521

16-
string requestUrl = string.Format("{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/properties?api-version={4}",
17-
baseUrl, azSubId, ResourceGroupName, ApiManagementName, GlobalConstants.APIVersion);
22+
string requestUrl = string.Format("{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.ApiManagement/service/{3}/properties?$skip={4}&api-version={5}",
23+
baseUrl, azSubId, ResourceGroupName, ApiManagementName, numOfProperties, GlobalConstants.APIVersion);
1824

19-
return await CallApiManagementAsync(azToken, requestUrl);
25+
numOfProperties += GlobalConstants.NumOfRecords;
26+
27+
string properties = await CallApiManagementAsync(azToken, requestUrl);
28+
29+
oProperty = JObject.Parse(properties);
30+
31+
foreach (var item in oProperty["value"])
32+
{
33+
propertyObjs.Add(item.ToString());
34+
}
35+
}
36+
while (oProperty["nextLink"] != null);
37+
38+
return propertyObjs.ToArray();
2039
}
2140

2241
public async Task<string> GetPropertyDetailsAsync(string ApiManagementName, string ResourceGroupName, string propertyName)
@@ -45,12 +64,12 @@ public async Task<Template> GenerateNamedValuesTemplateAsync(string singleApiNam
4564
List<TemplateResource> templateResources = new List<TemplateResource>();
4665

4766
// pull all named values (properties) for service
48-
string properties = await GetPropertiesAsync(exc.sourceApimName, exc.resourceGroup);
49-
JObject oProperties = JObject.Parse(properties);
67+
string[] properties = await GetPropertiesAsync(exc.sourceApimName, exc.resourceGroup);
5068

51-
foreach (var extractedProperty in oProperties["value"])
69+
foreach (var extractedProperty in properties)
5270
{
53-
string propertyName = ((JValue)extractedProperty["name"]).Value.ToString();
71+
JToken oProperty = JObject.Parse(extractedProperty);
72+
string propertyName = ((JValue)oProperty["name"]).Value.ToString();
5473
string fullPropertyResource = await GetPropertyDetailsAsync(exc.sourceApimName, exc.resourceGroup, propertyName);
5574

5675
// convert returned named value to template resource class

0 commit comments

Comments
 (0)