1

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 2

2

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

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your reply , this command can't run with manually webjob ?
@QuentinMerlin To run a specific triggered webjob you can try using az webapp webjob triggered run --name MyWebApp --resource-group MyResourceGroup --webjob-name MyWebjob.
Thanks ! Work like a charm
2

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

1 Comment

not working for me : Invoke-WebRequest : Windows PowerShell is in NonInteractive mode. Read and Prompt functionality is not available. i use azuredevops to run this command via Powershell task

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.