Reputation: 741
Is there any idea that shows how to trigger (or start) a azure web app webjob from azure devops task ( or via azure powershell) ?
Thank you,
Edit : i use the azure cli task in azure devops it's look no working
EDIT 2 : i'am wrong in name of slot the solution of @levi-lu-msft Works
Upvotes: 1
Views: 1596
Reputation: 30393
You can use the extension task Azure App Services (With WebJob) - Start and Stop to start a azure web app webjob.
You can also run below ac cli command in the azure cli task to start a webjob.
az webapp webjob triggered run --name MyWebApp --resource-group MyResourceGroup --webjob-name MyWebjob
You will need to connect your azure devops to Azure subscription by creating an Azure Resource Manager service connection
Upvotes: 2
Reputation: 2522
You can use Powershell to trigger Manual Azure Webapp Webjob.
The user name and password comes from their Publishing profile. (In the Azure Portal -> browse to Your App Service > Click on "Get Publish Profile")
The $username in the script should look like SomeUserName
, and not SomeSite\SomeUserName
$username = "`$username"
$password = "password"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$userAgent = "powershell/1.0"
$apiUrl = "https://<sitename>.scm.azurewebsites.net/api/triggeredwebjobs/<YourWebjobName>/run"
Invoke-WebRequest -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -UserAgent $userAgent -Method POST -Debug
Upvotes: 2