I want to trigger or call a azure webjob using my java application which is simple a spring boot application.
I have some questions like can we invoke or trigger the azure webjob using Spring Rest API call?
And if yes then how. webjob also require a username and password.
I tried something like:
@GetMapping
public String methodCall(@RequestHeader String username, @RequestHeader String password) {
String ApiUrl = "https://myapp.scm.azurewebsites.net/api/triggeredwebjobs/webjob";
RestTemplate resetTemplate = new RestTemplate();
StringBuilder sb = new StringBuilder().append(ApiUrl).append(username).append(password);
String response = resetTemplate.getForObject(sb.toString(), String.class);
System.out.println("response:----------" + response);
return response;
}
If you want to run a triggered azure web job, you can use the Azure REST API
For example
Create a service principal and assign Contributor Role to the sp
Code