Azure Administer WebJob

Octopus.Script exported 2015-11-23 by dustinchilson belongs to ‘Azure’ category.

Start, Stop, or Delete a WebJob from the Azure Web App

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Web App

WebJobWebApp

The Web App the Azure WebJob is hosted under.

User Name

WebJobUserName

The Username of the authentication to the Kudu Api.

See https://github.com/projectkudu/kudu/wiki/Deployment-credentials

Password

WebJobPassword

The Password of the authentication to the Kudu Api.

See https://github.com/projectkudu/kudu/wiki/Deployment-credentials

Action

WebJobAction

The action to perform. Start, Stop, or Delete.

Job Type

WebJobType = continuouswebjobs

The type of job, Continuous or Triggered

Job Name

WebJobName

The name of the Job to act upon.

Script body

Steps based on this template will execute the following PowerShell script.

$httpAction = 'POST'

if ($WebJobAction -eq 'delete') {
    $httpAction = 'DELETE'
}

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $WebJobUserName,$WebJobPassword)))
$apiUrl = "https://$WebJobWebApp.scm.azurewebsites.net/api/$WebJobType/$WebJobName/$WebJobAction"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method $httpAction -ContentType "Application/Json"

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "ac7868f9-dc5c-42b8-ab8c-0c1e801f6957",
  "Name": "Azure Administer WebJob",
  "Description": "Start, Stop, or Delete a WebJob from the Azure Web App",
  "Version": 2,
  "ExportedAt": "2015-11-23T20:15:06.113+00:00",
  "ActionType": "Octopus.Script",
  "Author": "dustinchilson",
  "Parameters": [
    {
      "Name": "WebJobWebApp",
      "Label": "Web App",
      "HelpText": "The Web App the Azure WebJob is hosted under.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "WebJobUserName",
      "Label": "User Name",
      "HelpText": "The Username of the authentication to the Kudu Api.\n\nSee https://github.com/projectkudu/kudu/wiki/Deployment-credentials",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "WebJobPassword",
      "Label": "Password",
      "HelpText": "The Password of the authentication to the Kudu Api.\n\nSee https://github.com/projectkudu/kudu/wiki/Deployment-credentials",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "Sensitive"
      }
    },
    {
      "Name": "WebJobAction",
      "Label": "Action",
      "HelpText": "The action to perform. Start, Stop, or Delete.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "Select",
        "Octopus.SelectOptions": "start|Start\nstop|Stop\ndelete|Delete"
      }
    },
    {
      "Name": "WebJobType",
      "Label": "Job Type",
      "HelpText": "The type of job, Continuous or Triggered",
      "DefaultValue": "continuouswebjobs",
      "DisplaySettings": {
        "Octopus.ControlType": "Select",
        "Octopus.SelectOptions": "continuouswebjobs|Continuous\ntriggeredwebjobs|Triggered"
      }
    },
    {
      "Name": "WebJobName",
      "Label": "Job Name",
      "HelpText": "The name of the Job to act upon.",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "$httpAction = 'POST'\n\nif ($WebJobAction -eq 'delete') {\n    $httpAction = 'DELETE'\n}\n\n$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes((\"{0}:{1}\" -f $WebJobUserName,$WebJobPassword)))\n$apiUrl = \"https://$WebJobWebApp.scm.azurewebsites.net/api/$WebJobType/$WebJobName/$WebJobAction\"\nInvoke-RestMethod -Uri $apiUrl -Headers @{Authorization=(\"Basic {0}\" -f $base64AuthInfo)} -Method $httpAction -ContentType \"Application/Json\""
  },
  "Category": "Azure",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/azure-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ZOJOk6Pg7HKMsrtQKcowzZoK3rx1ZUelGMdQA/HaKkjAt2RgqpZeYqbNbH7Hp2ct4nqfSPOfe0ftiSTZJydOV6rG5bQbyLK+nRuCC0343PzDgiOXyQA5c14BTZi98uR/5KJ1SnatLdoO50WWBQZPTq0VgsklU3h932actuo17ayrHrb/3ykiegd3KbqF2wbV6RrlsJ07yLcpsWFTul9RyK6ZScr+tk7oNrFj0o7HQUlj4EiEvJ6rPLKSmlMZCrksl1OnLaRkxc+/HB1naMhNtT/6yM2bDs6azCRHrM3aVPN7aW8irD/10B8njpAMcsl8okXcdKrl4sPsLmQVy/Sj90ucPRc/d/Bxxj+dXSpCayen32D+hLi16MsIV8gfCXrYp6ySsiJKRUF0XXiLpVbFU+fNv4r7mOwhFsX4ZdwpSi1DYs2jb6ebZ9788cblTzMrYhu7sf/17IFdtuviJ2ioHA6pMHkoH4CLUeMBU7iGkxuM/YgcdderF9ibRdc7O982F1HpYhjfWUe+x5a6pjop9iNLfoePvlsdZdTSMwfxSmTY20Q0eHnUNzga1edeNmmqbg18aMVR1L9vwSXHF9TfIWBxpKLs2hj3eQeBC0USvp2HHF3eIkRdhFOd6ER8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/I/4J8AAo/80BciBec4AAAAASUVORK5CYII=",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Monday, November 23, 2015