In this blog post, I will explain you how to deploy an Azure WebJob via a release definition in TFS Online.
I will assume that you know what is a WebJob and how to manage it, but also how to use and configure TFS Online. I’m considering that you have the WebJob already deployed and configured to your subscription.
Many blogs are telling that we have to convert our “WebJob Visual Studio solution” to a Web type project, then create a release and embed the WebJob code during the build.
It was too much steps for me so I looked after an easiest solution… J
This solution will work with all WebJobs types. Just for the Continuous type, an App Service restart will be required (this won’t be explained).
- Let’s configure the build definition :
- Get the Source code
- Restore the NuGet Package
- Use the build configuration as follow :
- Configure the copy as follow :
- Configure the publish artifacts as follow :
- Let’s configure the release definition :
For the release definition we’re going to use the FTP protocol to deploy our content to our App Service. You can retrieve the FTP connection’s information of your App Service via the publishing profile. Download and open it with notepad++ for instance. Look for FTP and you will find the server, user and password to connect.
- Create an environment and add the task FTP Upload
- In Authentication method, select Enter Credentials
- In Server , user and password, fill in with the info retrieved from the publishing profile
- Source Folder, select the …’s button next to the field and navigate to your code folder
- File Patterns, set ** to take everything
- In the remote repository, the example is for a scheduled WebJob. If it is your case, type the same as showed (/site/wwwroot/App_Data/jobs/triggered/MyWebJobName), but replace the “MyWebJobName” by the name of your WebJob defined during the creation. If you have any doubt of what is your folder, you can take an FTP tool (like FileZila) and navigate to this folder to see the exact path.
- In the advanced section, define as showed. Do not check the box clean remote repository, this will erase everything in the destination repository, which contain the schedule of your WebJob too.
Enjoy ! 🙂