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.
Related
I have a files in azure repro and i need to zip after that i need to
updated into azure webapp to with new webjob with
manually/continuous.
2.I have created Build Pipeline and Release Pipeline. WebJobs are not created in the azure webapp
Kindly please help on this issues if any one knows.
The processes you have taken are just publishing the demo.zip file to the default production slot in your Web App. It is not creating a WebJobs in the Web App.
I am afraid that you have misunderstanding on WebJobs of Web App. It is a feature of Azure App Service that enables you to run a program or script in the same instance as a web app, API app, or mobile app. There is no additional cost to use WebJobs.
To create a WebJob in your Web App, normally, you need to manually add the WebJob in the web UI of your Web App.
I have one asp.net sample application. I want to deploy this web application to the Azure web app, I used azure DevOps to build and release the pipeline.
I successfully completed the build and release but when I try to access the web app though the azure web app URL it reflects You do not have permission to view this directory or page.
How to rectify the problem?
You can visit https://{yourwebsitename}.scm.azurewebsites.net to check if your app files are deployed to site/wwwroot foler in Kudu server.
If your app files are deployed to folder site/wwwroot/appname. You need to check the Path mappings of your Application Settings. Then in the Virtual applications and directories section, You need to change your Physical path to "site/wwwroot/appname". You can find more details in this blog.
If above doesnot work out. You can do below steps to show more error messages and troubleshoot the issue.
Go to Your Web App in Azure> App Service logs >turn on Detailed Error Messages.
In the Web Config file add <customErrors mode="Off" /> under <system.web> tag, add <httpErrors errorMode="Detailed"></httpErrors> under <system.webServer> tag. And update the web.config file to your azure web app.
Check out this thread for details.
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.
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.
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.