call url on azure app service with authentication and authorization from Webjobs (or better way)

130 Views Asked by At

net 6 web app running on app service, with authentication over AAD + app roles on app registration, i need something that will call me specific action on that app service every 2hours for example

//action on web app
[Authorize(Roles = "Root")]
public IActionResult NeedToCallThis()
{
    //code
    return View();
}

when i create console app for WebJobs that will just try to call ....azurewebsites.net/Controller/NeedToCallThis it will ofc return auth website from microsoft, even if i run in on AppService WebJobs so i need some kind of authentication or if someone use powershell or something?

//console app for webjob
using System.Net;
var client = new WebClient();
var content = client.DownloadString("https://xxx.azurewebsites.net/cont/act");
Console.WriteLine(content);

More info: when i run webjob i will get this in logs of webjob: enter image description here same login page of microsoft will returns me powershell script that calls web application

your answears are not bad but i dont have problem with setting schedule on webjobs, that is fine but when i run the webjob that should trigger me web application i need some kind of authentication or i dont know

0

There are 0 best solutions below