첫 번째 웹 작업을 종료하려면 어떻게해야합니까?
첫 번째 WebJob에서 예외를 처리하기 위해 try-catch를 사용하는 것이 좋습니다. 예외가 발생하면 다른 WebJob을 시작하기 위해 대기열에 blob 이름을 쓸 수 있습니다.
public static void ProcessCSVFile([BlobTrigger("input/{blobname}.csv")] TextReader input, [Queue("myqueue")] out string outputBlobName, string blobname)
{
try
{
//process the csv file
//if none exception occurs, set the value of outputBlobName to null
outputBlobName = null;
}
catch
{
//add the blob name to a queue and another function named RepeatProcessCSVFile will be triggered.
outputBlobName = blobname;
}
}
다른 WebJob에 QueueTrigger 기능을 만들 수 있습니다. 이 함수에서 blob 이름을 읽고 csv를 다시 처리 할 수 있습니다. 새로운 예외가 발생하면 큐에 blob 이름을 다시 추가 할 수 있으며이 함수는 csv 파일이 성공적으로 처리 될 때까지 계속해서 다시 실행됩니다.
public static void RepeatProcessCSVFile([QueueTrigger("myqueue")] string blobName, [Queue("myqueue")] out string outputBlobName)
{
try
{
//process the csv file
//if none exception occurs, set the value of outputBlobName to null.
outputBlobName = null;
}
catch
{
//re-add the blobName to the queue and this function will be executed again until the csv file has been handled successfully.
outputBlobName = blobName;
}
}
코드에서 예외가 발생할 경우이 예외가 필요하지 않으므로 적절한 예외 처리는 어떻게됩니까? 그렇지 않으면 아마도 도움이 될 수 있습니다. https://github.com/Azure/azure-webjobs-sdk-extensions#errortrigger? 또한이 답변을 살펴보십시오. https://stackoverflow.com/questions/35166010/azure-triggered-webjob-detecting-when-webjob-stops –
작업을 확장하는 방법은 무엇입니까? 처리하는 동안 BLOB가 잠겨 있다고 확신합니다. – Thomas
@ 토마스. Blob은 파일을 잠그지 않습니다. 그들 (두 개의 웹 작업)이 컨테이너에 새로운 BLOB를 가지고있는 동안, 두 웹 작업에 대한 Blob Trigger가 실행을 시작합니다. – ABB