我有一个Azure Logic应用程序请求/响应,它正在查询SQL DB并给出响应:
{
"Table1": [{
"IP": "123"
}, {
"IP": "12345678"
}, {
"IP": "7777"
}, {
"IP": "999999"
}]
}
但我想改为像平面文字文件:
123
12345678
7777
999999
这可能吗?
答案 0 :(得分:1)
您可以轻松解决添加Azure功能的问题,该功能将提取您需要的信息并从您的逻辑应用程序中调用它:
https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-azure-functions
#r "Newtonsoft.Json"
using System.Net;
using Newtonsoft.Json;
public class Table1
{
public string IP { get; set; }
}
public class RootObject
{
public List<Table1> Table1 { get; set; }
}
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
// Get request body
dynamic data = await req.Content.ReadAsAsync<object>();
var root = JsonConvert.DeserializeObject<RootObject>(data.ToString());
var ips = new List<string>();
foreach(var table1 in root.Table1)
ips.Add(table1.IP);
var output = string.Join("\n", ips);
return req.CreateResponse(HttpStatusCode.OK, output);
}