[Azure Functions] Queue Storage 바인딩에서 Function에서 다른 Function을 호출합니다.
소개
Azure Functions Queue Storage을 사용하여 한 Function에서 다른 Function을 호출하는 단계를 보여 줍니다.
소스 코드 → htps : // 기주 b. 코 m / 모모 타로 98 / 아즈레 펑 c 치온 s 쿠에 우에 s 토라 게 mp ぇ
대상자
전제 조건
사전 준비
Azure Functions에서 Queue Storage를 사용하려면 다음을 수행해야 합니다.
Azure Storage에서 Queue Storage 만들기
① Azure Portal 화면에서 "Storage Accounts"를 선택
② 생성된 Azure Functions 앱과 연결되어 있는 Storage Account를 선택한다
③ "Queues"를 선택하고 "+Queue"버튼에서 작성하고 싶은 이름의 큐를 만든다

Microsoft Azure Storage Explore를 사용하여 대기열 확인
만든 테이블의 콘텐츠에 액세스하려면 Microsoft Azure Storage Explore(무료)라는 Microsoft에서 제공하는 전용 클라이언트 앱을 사용해야 합니다. (Windows, Mac, Linux 3개 모두 앱 있음)
앱을 다운로드하고 Queues에 만든 대기열이 있는지 확인합니다.

Queue Storage 바인딩에서 Function에서 다른 Function 호출
본 기사에서는 시간 트리거형의 Function이 Queue 트리거의 Function을 발화한다고 하는 구성의 2개의 Function을 기술합니다.
호출할 Function
Queue Storage를 사용하여 다른 Function을 호출하는 측의 Function에서 "Outpus"에 Queue Storage를 설정합니다.


구현
function.json{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */5 * * * *"
},
{
"type": "queue",
"name": "outputQueueItem",
"queueName": "sample-queue",
"connection": "AzureWebJobsDashboard",
"direction": "out"
}
],
"disabled": false
}
run.csxusing System;
public static void Run(TimerInfo myTimer, ICollector<string> outputQueueItem, TraceWriter log)
{
// Call CalledFunction by using queue
outputQueueItem.Add("queue-string");
}
호출되는 Function
Queue Storage를 사용하여 호출되는 측의 Function을 작성합니다.
아래 그림과 같이 신규 Function 작성에서 "QueueTrigger"의 Function 형식을 선택하고, "Queue name"에는 Storage Accounts로 작성한 큐명을 지정합니다.

구현
호출되는 Function의 구현입니다.
function.json{
"bindings": [
{
"name": "myQueueItem",
"type": "queueTrigger",
"direction": "in",
"queueName": "sample-queue",
"connection": "AzureWebJobsDashboard"
}
],
"disabled": false
}
run.csxusing System;
public static void Run(string myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
}
실행
함수 호출자인 CallerFunction
실행합니다.
C# Queue trigger function processed: queue-string
호출측이 큐에 붙인 queue-string
를 트리거로서 호출되어 측의 Function 가 실행되는 것을 확인할 수 있었습니다.
결론
Function간의 교환은 향후 Durable Function이라고 불리는 플랫폼이 전개되어 가는 것 같습니다.
htps : // / cs. mic로소 ft. 코 m / 엔 - s / 아즈레 / 아즈레 - 펑 c 치온 s / 즈라 b ぇ - 펑 c 치 온 s - 오 r ゔ ぃ w
이쪽의 동향도 억제해 가고 싶습니다.
참고
{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */5 * * * *"
},
{
"type": "queue",
"name": "outputQueueItem",
"queueName": "sample-queue",
"connection": "AzureWebJobsDashboard",
"direction": "out"
}
],
"disabled": false
}
using System;
public static void Run(TimerInfo myTimer, ICollector<string> outputQueueItem, TraceWriter log)
{
// Call CalledFunction by using queue
outputQueueItem.Add("queue-string");
}
{
"bindings": [
{
"name": "myQueueItem",
"type": "queueTrigger",
"direction": "in",
"queueName": "sample-queue",
"connection": "AzureWebJobsDashboard"
}
],
"disabled": false
}
using System;
public static void Run(string myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
}
C# Queue trigger function processed: queue-string
Function간의 교환은 향후 Durable Function이라고 불리는 플랫폼이 전개되어 가는 것 같습니다.
htps : // / cs. mic로소 ft. 코 m / 엔 - s / 아즈레 / 아즈레 - 펑 c 치온 s / 즈라 b ぇ - 펑 c 치 온 s - 오 r ゔ ぃ w
이쪽의 동향도 억제해 가고 싶습니다.
참고
Reference
이 문제에 관하여([Azure Functions] Queue Storage 바인딩에서 Function에서 다른 Function을 호출합니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/momotaro98/items/35fb835ce92e5d5bacb2텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)