|
4 | 4 | using System.Collections.Generic;
|
5 | 5 | using Newtonsoft.Json;
|
6 | 6 | using Newtonsoft.Json.Linq;
|
| 7 | +using System.Linq; |
7 | 8 |
|
8 | 9 | namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Extract
|
9 | 10 | {
|
10 | 11 | public class PropertyExtractor : EntityExtractor
|
11 | 12 | {
|
12 |
| - public async Task<string> GetPropertiesAsync(string ApiManagementName, string ResourceGroupName) |
| 13 | + public async Task<string[]> GetPropertiesAsync(string ApiManagementName, string ResourceGroupName) |
13 | 14 | {
|
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(); |
15 | 21 |
|
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); |
18 | 24 |
|
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(); |
20 | 39 | }
|
21 | 40 |
|
22 | 41 | public async Task<string> GetPropertyDetailsAsync(string ApiManagementName, string ResourceGroupName, string propertyName)
|
@@ -45,12 +64,12 @@ public async Task<Template> GenerateNamedValuesTemplateAsync(string singleApiNam
|
45 | 64 | List<TemplateResource> templateResources = new List<TemplateResource>();
|
46 | 65 |
|
47 | 66 | // 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); |
50 | 68 |
|
51 |
| - foreach (var extractedProperty in oProperties["value"]) |
| 69 | + foreach (var extractedProperty in properties) |
52 | 70 | {
|
53 |
| - string propertyName = ((JValue)extractedProperty["name"]).Value.ToString(); |
| 71 | + JToken oProperty = JObject.Parse(extractedProperty); |
| 72 | + string propertyName = ((JValue)oProperty["name"]).Value.ToString(); |
54 | 73 | string fullPropertyResource = await GetPropertyDetailsAsync(exc.sourceApimName, exc.resourceGroup, propertyName);
|
55 | 74 |
|
56 | 75 | // convert returned named value to template resource class
|
|
0 commit comments