How to automatically deploy a web job to Azure portal using Power shell

Thanks for pitching in everyone! Your input was helpful, however I would like to update the answer with the solution I found that was so easy and saved me so much time. I will like to update you on how I could successfully deploy the app service and web job in a single go. Its very easy and since it deploys web app and corresponding web jobs in a single go, this was the perfect solution for my scenario. Thanks to my colleague who helped me with this solution. The following depicts the steps I had to go through.

Lets suppose that my app service in Azure is “appService1” and I want to create a triggered web job under appService1 that goes by the name “webJob1”. I followed zip-deployment with azure cli.

  1. Publish your web application (For the app service) solution in release mode to get the files you will have to deploy. Let this folder be WebAppBuild.
  2. Build your application (a console application in my case) that would serve as the web job for the app service in release mode.
  3. Inside the published folder for the web application (for app service ie WebAppBuild in our example), add a folder with the following path

app_data\jobs\triggered\webJob1

(If you need more than one web jobs deployed, you can create more than one folders like webJob2, webJob3 etc)

Add the files you have in step 2 to this folder. This is basically the files needed for your web job

  1. Zip the contents in a single folder that acts as your deployment folder for web app and web job
  2. Go to powershell and run az login (works if you have installed azure cli, otherwise you will have to install it as well)
  3. Log into your respective account with the prompt window
  4. Run the following commands that sets run from package property to true for your web app and the second command is the actual deployment command
az webapp config appsettings set --resource-group <<resourceGroupName>> --name <<appServiceName>> --settings WEBSITE_RUN_FROM_PACKAGE="1" ; 
az webapp deployment source config-zip --resource-group <<resourceGroupName>> --name <<appServiceName>> --src <<zipFilePath>>

  1. Now login to your azure portal and navigate to your web app. Check under web jobs option and you will see that the web job has been created with the files you deployed.

For more help on starting, stopping, deleting the web job with azure cli, go through the following document. Check here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top