1
votes

My Requirement:

As soon as a file being uploaded to a Blob Container, the Azure Function is being alerted and withing that Azure Function I want to call a Webjob who uses the uploaded file and does any task.

What I learnt:

I learnt that Azure Function can be triggered when a file being uploaded to a blob container. I tried the tutorials and was able to configure an Azure function and it acts for any change in blob container. I did this via Azure Portal and not used Visual Studio.

Now I want to call a WebJob within the Azure Function. Please help me on this.

1
Why not put the code in the function instead of the webjob? - Peter Bons
@PeterBons Thank you. Glad to know that I can have extra code in the function. Let me try it - hiFI
@PeterBons I could not find resource pertaining to this subject and prompts me to inquire if my function is built in-portal, can I add more code to it to customize my requirement - hiFI

1 Answers

1
votes

Assuming that you have written your function in C#, below is the code that might help you. Essentially the idea is to send a POST request to trigger your job:

HttpClient client = new HttpClient();
client.BaseAddress = new Uri(“https://your_web_site.azurewebsites.net/api/”);
var byteArray = Encoding.ASCII.GetBytes(“your_username:your_password”);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(“Basic”, Convert.ToBase64String(byteArray));  
var response = await client.PostAsync(“triggeredwebjobs/your_web_job_name/run”, null);

Username and password you find in Azure portal, in the properties of your job.