큐에서 배치 메시지를 읽고 모든 json을 하나로 추가하는 방법
여기 내가 가진 것입니다
5 개의 메시지가있는 경우 간단한 트리거 논리 앱이 큐에서 읽을 수 있도록 wan 다음 하나에 JSON을 추가해야합니다. 예를 들어 아래를 참조하십시오 (올바른 순서인지 확실하지 않음). 대기열은 다음과 같습니다.
[ { "fname":"1", "lname":"1" } ]
[ { "fname":"2", "lname":"2" } ]
[ { "fname":"3", "lname":"3" } ]
[ { "fname":"4", "lname":"4" } ]
[ { "fname":"5", "lname":"5" } ]
그런 다음 예상되는 JSON 출력
[
{
"fname": "1",
"lname": "1"
},
{
"fname": "2",
"lname": "2"
},
{
"fname": "3",
"lname": "3"
},
{
"fname": "4",
"lname": "4"
},
{
"fname": "5",
"lname": "5"
}
]
***********************************************최신 정보** ************************************************** ***
이제 이메일이 한 번만 전송되어야합니다. 여러 번 전송됩니다 .. 예 : [{ "fname": "1", "lname": "1"}, { "로 하나의 이메일을받는 대신 fname ":"2 ","lname ":"2 "}
하나의 이메일을받습니다. [{ "fname": "1", "lname": "1"}]
그런 다음 다른 이메일 [{ "fname": "1", "lname": "1"}, { "fname": "2", "lname": "2"}]
기본적으로 JSON의 최종 결과를 얻어야 나중에 데이터베이스에 전달할 수 있습니다.
I don't know why did you use "Get message from a queue" action in your logic app. According to my understanding, you create a batch sender to send the five messages, then trigger the batch receiver. And you want to convert the five json message to the format you expected. So I provide my test steps below for your reference. (in my logic app, I set the "Message Count" as "3" for ease of testing)
1. I created a batch receiver trigger and below is all of the actions under the batch receiver.
2. Then the details of the "For each" loop shown as below:
The expression in the screenshot above is:
union(variables('result'), items('For_each')['content'])
3. You'd better modify the setting of the "For each" loop by click the "Settings" and enable "Concurrency Control" and change the "Degree of Parallelism" to "1".
4. Then I create another logic app as the batch sender.
Run this logic app(batch sender) three times, send the json messages one by one.
5. Now go back to the first logic app(the batch receiver), and check the result
variable in the third loop of the "For each" loop(in logic app "runs history"). We can see the result shown as below:
Update:
Change step4(the batch sender logic app) as below:
4.1 Initialize a variable named "message" and use "Get messages from a queue (peek-lock)" action to get the messages in your queue.
4.2 Use a "For each" to loop the "Body" from the queue and use the variable "message" to store the "Content" of the queue in each loop. Then put the variable "message" into the batch sender.(please note we can't put the "Content" into the batch sender directly because the "Content" is like a binary string, we need to use a variable to store then put it into batch sender, then it will be the json [ { "fname":"1", "lname":"1" } ]
). Don't forget to change the setting of this "For each" action, otherwise the result will be incorrect.
2.1 2 단계에서 식을 다음과 같이 변경하십시오.
union(variables('result'), items('For_each')['content'])
...에
union(variables('result'), json(items('For_each')['content']))
업데이트 2 :
일괄 수신기 논리 앱에서 "result"라는 변수를 초기화하고 "For each"에 각 루프의 최신 json 값을 저장하는 데 사용됩니다. 따라서 "Send an email (v2)"을 "For each"외부로 이동하고 "Body"로 변수 "result"를 사용하여 이메일을 보내십시오. 아래 내 논리 앱을 참조하십시오.
"Send an email (v2)"액션을 "For each"루프 밖으로 옮기고 변수 "result"를 이메일의 "Body"에 넣으십시오. 그러나 "Dynamic content"에서는 찾을 수 없으므로 표현식으로 입력하십시오.
그 후에는 논리 앱에서 하나의 이메일 만 수신됩니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다