private void GenerateProductsARMTemplate(string apimname, string resourceGroup, string fileFolder) { APIExtractor apiExtractor = new APIExtractor(); Template armTemplate = GenerateEmptyTemplateWithParameters(); List <TemplateResource> templateResources = new List <TemplateResource>(); string products = apiExtractor.GetProducts(apimname, resourceGroup).Result; JObject oProducts = JObject.Parse(products); foreach (var item in oProducts["value"]) { string productName = ((JValue)item["name"]).Value.ToString(); Console.WriteLine("'{0}' Product found", productName); string productDetails = apiExtractor.GetProductDetails(apimname, resourceGroup, productName).Result; ProductsDetailsTemplateResource productsDetailsResource = JsonConvert.DeserializeObject <ProductsDetailsTemplateResource>(productDetails); productsDetailsResource.name = $"[concat(parameters('ApimServiceName'), '/{productName}')]"; productsDetailsResource.apiVersion = "2018-06-01-preview"; templateResources.Add(productsDetailsResource); } armTemplate.resources = templateResources.ToArray(); FileWriter fileWriter = new FileWriter(); fileWriter.WriteJSONToFile(armTemplate, @fileFolder + Path.DirectorySeparatorChar + apimname + "-products.json"); }
private void GenerateProductsARMTemplate(string apimname, string resourceGroup, string fileFolder) { APIExtractor apiExtractor = new APIExtractor(); Template armTemplate = new Template() { schema = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", contentVersion = "1.0.0.0", parameters = new Dictionary <string, TemplateParameterProperties> { { "ApimServiceName", new TemplateParameterProperties() { type = "string" } } }, variables = { }, resources = { }, outputs = { } }; List <TemplateResource> templateResources = new List <TemplateResource>(); string products = apiExtractor.GetProducts(apimname, resourceGroup).Result; JObject oProducts = JObject.Parse(products); foreach (var item in oProducts["value"]) { string productName = ((JValue)item["name"]).Value.ToString(); Console.WriteLine("'{0}' Product found", productName); string productDetails = apiExtractor.GetProductDetails(apimname, resourceGroup, productName).Result; ProductsDetailsTemplateResource productsDetailsResource = JsonConvert.DeserializeObject <ProductsDetailsTemplateResource>(productDetails); productsDetailsResource.name = $"[concat(parameters('ApimServiceName'), '/{productName}')]"; productsDetailsResource.apiVersion = "2018-06-01-preview"; templateResources.Add(productsDetailsResource); } armTemplate.resources = templateResources.ToArray(); FileWriter fileWriter = new FileWriter(); fileWriter.WriteJSONToFile(armTemplate, @fileFolder + Path.DirectorySeparatorChar + apimname + "-products.json"); }