stop automatic deployment of webjob - azure

I have a webapp in which a webjob is linked.
Since it is linked to webapp, so it auto deploys with webapp.
My issue is that i want to deploy only webapp not webjob.
Is there any way i can stop automatic deployment of webjob?

If you create your WebJob using following steps, a file named webjobs-list.json will be created under your properties folder.
Right click your project -> Add -> New Azure WebJob Project
The file will link your web application to the WebJob project. If we publish the web application, the WebJob project will also be published in the same Azure Web App.
My issue is that i want to deploy only webapp not webjob. Is there any way i can stop automatic deployment of webjob?
You can delete the webjobs-list.json file under your properties folder to remove the relationship between your web application and your WebJob. After that, the WebJob project will not be published when you publish your web application.
Since our WebJobs are exist in the app_data folder of our web application, if we check the [Remove additional files at destination] option, all the files under our web application will be deleted(include the WebJob files). If you don't want your WebJob be affected when you publish your web application, please keep the [Remove additional files at destination] option unchecked.

Related

Deploying several webjobs and a webapi to a single App Service on Azure with Devops

I am trying to deploy 4 or more webjobs and a webapi to a single app service on Azure, using Azure Devops.
I have read previously that to deploy a webjobs i needed to prp my artefact with the following tree organisation : webjobs/app_data/jobs/continuous ou webjobs/app_data/jobs/triggered
So i made it so that my build prepared the artefacts organised like this :
artefact
/WebApi
/...dlls and stuff
/webjob
/app_data
/jobs
/continuous
/webjob1
/...
/webjob2
/...
/triggered
/webjob3
/...
/Webjob4
/...
When i deploy webjobs, using the task Azure App Service Deploy, and pointing the folder webjob, i can see my webjobs being deployed all well.
But when i try to deploy the webApi as well, it doesn't work.
I first tried to deploy webjobs and webapi in two separated task (still using Azure App Service Deploy ) but one was overwritting the others.
I then tried using one task Azure App Service Deploy, by providing the top folder containing WebApi and webjob, but this doesn't seem to work.
I suppose there is a simple thing to do here, but i don't seem to be able to work it out ...
Is there any people who have managed to do this ?
Check this case: How do you deploy an Azure WebJob and App to the same App Service via VSTS?
You need to associate webjobs with web app, by right clicking your Web App project in Visual Studio and select Add > Existing Project as Azure WebJob and follow the wizard.
The webjobS are included in the web app package, then you just need to deploy web app to azure app service.
It will generate webjob’s package too during publishing (that why there are two zip files), but you just need to specify web app package in Azure App Service deploy task. (Check Publish using Web Deploy option). Make sure the "Exclude files from the App_data folder" is unchecked:

Publishing WebJob to Azure overrwrites website NLog.config

I use VS2017 to publish my .NET web application to Azure App Service, and a .NET console application to Azure WebJobs.
When I publish the console application, the NLog.config file in my web application root gets overwritten by the console application's NLog.config. These NLog.config files are not identical, and therefore it breaks the logging of my web app.
I have discovered that WebJobs are published to the App_Data folder of the web application, so each has it's own NLog.config:
Web Application: wwwroot\NLog.config
WebJob: wwwroot\app_data\jobs\triggered\MyWebJob\NLog.config
If I publish the WebJob first, then the web application, all is good. However that means each time I change & publish the WebJob, I have to re-deploy my web app.
Any suggestions how to resolve this? Or even some path to better diagnosing the issue?
Thanks.

How to publish asp.net core web job to azure app service

I have started with asp.net core 2 web app and I can publish it to App Service from Visual Studio using web deploy.
I've created new clean .net core 2 console app. I'm able to upload it as webjob and run using Azure Portal, but how do I publish it from local command line or Visual Studio?
Basically, I don't care whether it will be published alongside the Web Application or as standalone.
EDIT: I've somehow managed to get the publish dialog by right clicking the project and selecting Publish (not Publish as Azure WebJob) as menioned in the docs. But I still don't know what did the trick. Installing Azure SDK? Adding webjob-publish-settings.json? Adding Setting.job?
Publish .net core as webjob with Azure portal:
As you know:
A WebJob looks for specific file type, for example (.cmd, .bat, .exe, etc…)
To run a .NET Core console application you use the DOTNET command
Therefore, you need to create a file with an extension which is WebJob looking for that executes.
1.You could create a .net core conosole application. After running it, you will have the follow file in your projectname/bin/Debug/netcoreapp2.0
2.Create a run.cmd file under it. And the run.cmd content is as below:
#echo off
dotnet ConsoleApp7.dll
3.To deploy the .NET Core console application to an Azure App Service Web App Web Job access the Azure portal and navigate to the Azure App Service where you will host the WebJob.
Click on the WebJobs link and the Add button.
4.Upload the netcoreapp2.0.zip
5.Once the WebJob is successfuly uploaded, it will render in the WebJob blade. Click on it and you will see the Run button.
6.When you write output to the console using the WriteLine() method, it will show in the Run Details window on KUDU/SCM.
For more detail, you could refer to this article and this one.
Update:(publish with command line)
1.First, download your publish settings file of your webapp from Azure Portal.
2.Prepare the .zip folder you have created.
As David said, you could use WAWSDeploy to publish webjob with command line.
You could download WAWSDeploy with this link.
3.Then go to WAWSDeploy/bin/Debug folder to open the local command line.
Try the following command to deploy the webjob:
WAWSDeploy.exe DotNetCoreWebJobSample.zip [WEBSITE_NAME].PublishSettings /t app_data\jobs\triggered\DotNetCoreWebJobSample /v
Target directory will be app_data\jobs\triggered\[WEBJOB_NAME]. If this web job is a continuously running one, replace triggered with continuous.
Note:you could put the WAWSDeploy.exe and publish settings file and the .zip into a folder. If not, you should give the full path of publish settings and .zip file. So that you could publish webjob successfully.
For more detail about WAWSDeploy, refer to this article.
Make sure your csproj includes correct SDK's:
<Project Sdk="Microsoft.NET.Sdk;Microsoft.NET.Sdk.Publish">
Then just right click on the project in Visual Studio and click publish, select Microsoft Azure App Service and you should see the WebJob publish options:
Also notice that you should use Microsoft.NET.Sdk and not Microsoft.NET.Sdk.Web
If you are using Microsoft.NET.Sdk.Web, Visual Studio assumes that you are deploying to WebSite and not WebJob. The publish dialogs are slightly different for WebSite and WebJob. For example, for WebJob project you can specify WebJob Name.
You might be interested in:
github/aspnet/websdk/issue: WebJob publishing for Microsoft.NET.Sdk.Web
github/aspnet/Mvc/issue: How to publish console app as a WebJob rather than Web App
There is a great articel about Develop and deploy WebJobs using Visual Studio - Azure App Service that covers your question.
Basically after installing the prerequisites (depending on your VS version) you can
Right-click the Console Application project in the Solution Explorer, and then click Publish as Azure WebJob.

Azure: Publishing a web application removed my webjob on same app service

I have a Azure solution (provider web to my SharePoint app, but that shouldn't matter). I have created one app service where I publish my web application and I also have a web job which I want to have on same app service
I Deploy this web job separately by uploading the zip-file (or ps1-file) in the web job-part of my app service. Se image below
BUT: If I redeploy my web application (from Visual Studio) the web job is removed!
The best thing would be to include the web job in the deployment of the deployment of the web application, but in any case I just dont want it to be removed when I deploy the web application.
Any good solutions/suggestions?
If you look under the Settings tab on the Publish to Azure dialog in Visual Studio, there is a checkbox labeled "Remove Additional Files at Destination". Make sure this is unchecked. If it is checked, all additional files that are not in your Visual Studio solution will be removed.

Add Azure WebJob to mobile service hosted in App Service

With the new Azure Mobile App Services in Azure the mobile services apparently gains the same WebJob support as Websites have had for a while.
Following the article Deploy WebJobs using Visual Studio according to the section 'Enable automatic WebJobs deployment with a web project' we should be able to add a web job from a right click on the project. None of these options show up for my mobile service project in VS.
I can add a WebJob project to the solution manually, but this does not add the webjobs-list.json file to my mobile service project as the article suggests.
Does anyone know why the add web job context menu doesn't show when right-clicking on the mobile service project? Or the manual steps required to configure the project and appropriate webjobs-list.json file?
Update:
I have manually added the webjobs-list.json file to the main project by copying the format from another initial template project and adjusted the web job project path in it. Even deploying the mobile service to an azure web app doesn't pick up the web job.
It should work. I just created a new Mobile App, downloaded the quickstart, right-clicked the web project (appname-code), and was able to associate a webjob to the web project. Deployment worked as planned. Did you try that workflow? Did you try adding the webjob through the portal?

Resources