Trigger azure Webjob from powershell / azure devops

Viewed 538

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

2 Answers

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
Related