Reputation: 21
In Azure, I have a WebAPI and a WebJob. WebAPI sends messages to an Azure Service Bus queue, and the WebJob is the only subscriber of that queue. When the WebJob finalizes a processing job, how can it then pass a response message to the WebAPI?
Upvotes: 0
Views: 772
Reputation: 8491
You could create an API to accept the response from WebJob. Code below is for your reference.
public class WebJobResponseController : ApiController
{
public string Get(string token, string value)
{
//use the token to validate the webjob, use the value to post any data which you want to send to API
return "success";
}
}
On your WebJob side, after processed the job, you just need to send a request to the upper API. Code below is for your reference.
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("URL of your API");
await client.GetAsync("WebJobResponse?token=token1&value=value1");
Upvotes: 1