To deploy an Azure WebJob in an Azure DevOps CI/CD pipeline you'll want to use the AzureRMWebAppDeployment
task. The documentation for the AzureRMWebAppDeployment
task can be found here: AzureRmWebAppDeployment@4 - Azure App Service deploy v4 task.
In order to use the AzureRMWebAppDeployment
task to deploy an Azure WebJob. You will first need to create the Azure your text
WebJob in the Azure Portal.
- Steps to create a continuous or triggered Azure WebJob in Azure Portal:
Now that you have an Azure WebJob created in the Azure App Service you can use the AzureRMWebAppDeployment
to deploy new versions of your Azure WebJob.
The scenario below assumes you will be deploying a WebJob as .NET Framework console app as a Package (compressed zip file). The compressed zip file needs to have a specific rooted folder structure App_Data/jobs/continuous
for continuous and App_Data/jobs/triggered
for triggered in order to be deployed as a WebJob. Azure WebJobs deploy to those folders in your Azure App Service (i.e. wwwroot\app_data\jobs\triggered\{job name}
or wwwroot\app_data\jobs\continuous\{job name}
.
The Console development tool is useful in diagnosing deployment issues Working with Files in Azure App Service.
The below Azure DevOps YAML assumes you've stored your Azure WebJob Package in $(Build.ArtifactStagingDirectory)
and that you'll be using a Pipeline Service connection Manage service connections to your Azure Subscription.
See the documentation for the AzureRmWebAppDeployment@4 task for description on each of the inputs.
Here's the YAML task snippet to deploy your Packaged Azure WebJob
steps:
- task: AzureRmWebAppDeployment@4
displayName: 'Deploy: Azure WebJob'
inputs:
azureSubscription: '<Service Connection to Azure Resource Manager for your Azure Subscription>'
WebAppName: '<Azure App Service name>'
packageForLinux: '$(Build.ArtifactStagingDirectory)/<azurewebjobpackage>.zip'
enableCustomDeployment: true
DeploymentType: zipDeploy