Azure appservice adding webjob failing - azure

Every time i am trying to add a webjob under app service i am getting failure message. Previously it was working, from last 2 weeks i am not able to create a webjob.
Tried adding webjobs 50+ times
When i am trying to add manually through kudu its uploaded but under webjobs nothing created.
Error message Failed to add "Webjob name".
trying to create webjobs in azure portal>appservice>webjob>create new

I suppose this problem occurs because you don't have a specific file that webjob need.
I create a .net core console app, after publish it, I zipped the folder and want to upload it as a webjob.
failed, as yours.
The solution is add a .cmd file in the folder and zip it with other files.
run.cmd:
#echo off
dotnet ConsoleApp1.dll
Now, these are the whole content that will inside the zip:
zip these files and upload.
Finally, works.
I hope this solution can help you. Please let me know if your problem is different from this.

In my case, the problem was in publish profile. You need to configure your publish artifact according to the App Service configuration.

In my case, the executable file (exe, bat, cmd, etc.) needed to be in the root of the zip for it to work.

Related

Azure App Service keeping old files at /home/site/wwwroot/

I'm deploying nodejs application to Azure App Service with visual studio code extension (Deploy to web app). However when I inspect the files section, I found some old file/ files from previous deployment are still exist at /home/site/wwwroot/ folder.
For example first deployment have A.js, and second deployment I renamed it to B.js, /home/site/wwwroot/ will endup with A.js and B.js.
How can I resolved this issue? Any suggestion will be appreciated, thank you!
on publish page click on show all settings.
Make sure Remove additional files at destination.
Before check Remove additional files at destination. showing old file on wwwroot folder.
After check Remove additional files at destination. showing old file on wwwroot folder.

ASP.NET Core, Could not find file. How Can I publish it?

I have found many questions like this, but I'm still having problems to get a "static" file.
The task should be simple. Just get a cshtml file content. A file that it's already in the project. But it's taking forever to figure it out.
This is the error that I'm getting (only when in production)
Could not find file 'D:\home\site\wwwroot\AppData\template.cshtml'.
Looking into the 'D:\home\site\wwwroot' folder, indeed the 'AppData' doesn't exist. But then how can I publish the AppData and its files?
This is how I'm getting the file
string contentRootPath = webHostEnvironment.ContentRootPath;
return $"{contentRootPath}/AppData/{filename}";
This is inside .csproj
<Folder Include="AppData\" />
To publish the project I'm using DevOps Azure. Is there any configuration that I'm missing?
I don't know if this is the right approach, but it's working (for now).
In DevOps/Pipelines/MyMypeline/Tasks, I add Copy files Task.
Source Folder: MyProject/AppData
Target Folder: $(Agent.TempDirectory)\WebAppContent\AppData
The next task (Archive files) it was already set. So in resume, the pipeline will get the files from AppData and add in the same place where the solution was build. And the other task will zip all. Than another task (Azure Web App) will sent the zip to my AppService.
I still have to test when do the swipe from dev to prod, but for now that's it.

Is there a way I can publish an exe file to be in the same directory as an azure web job?

I have a web job that uses an exe that is best called when it is sitting in a directory and can be located. The problem is that I don't know how to get this exe to be published with the web job. I tried using a resources folder in the webjob project and copying them to output directory but that didn't upload them and so the only other option I can think of is uploading the files to a non temporary directory on the web site but that is leaking the encapsulation of the web job.
Any thoughts?
When you use visual studio to publish a webjob, it publishes all its dependencies as well. ie VS pushes all the dependencies available under the bin folder. So, add a reference to the dependent project and VS will take care of publishing this dependency as well.

Azure Website Continuous Deployment always picks up the wrong project

I have the following folder structure in my TFS online:
The folder names also match the project names in the solution.
Legend:
green dot: web api 2.0 project
red dot: class library
blue dot: console app added as a webjob to the web project
grey dot: console app only used for testing
Working folders for build definition:
The build definition was created automatically by connecting Azure to TFS online, and I have only changed the folder, so instead of the Team Project root folder, it points to the folder of this branch, containing the solution file and the folders in the first picture.
(This points to the folder which contains the solution files as well as all the subfolders from the first image.
Problem:
When I run a build, it always picks up the ExpiringRateCardsWorker project (even now the Web project has been renamed (both the directory and the project file) to start with an underscore, so it will be first alphabetically.
The deployment is successful, this is what I see in Monaco:
How can I make it pick up the web project?
Edit: Question was closed stating to be the duplicate of this. I have since tried the solution suggested there, but the /site/deployments folder is empty on the FTP, it doesn't contain the deploy.cmd, so my question is still not answered unfortunatelly.
I'm experiencing similar problem with deployment of MVC application to Azure using CD in VSO.
This problem is somehow related to WebJob Publishing mechanism.
For now I wasn't able to deploy my whole solution with WebJob in one go, but when I've deleted all webjob *.json files and Microsoft WebJobs Publish NuGet package from my solution, I've managed to deploy my MVC App normally.
I think I'll have to deploy this parts of the application separately, for now.

Force Azure Publish to create empty folder

I use Azure websites and my project must have an empty folder on the server. When I publish the project from the Solution Explorer (VS 2013), I don't get it created on the server.
For now, I keep an empty file there to force the creation but I was wondering if there is a proper way to make the publish process create it for me.
Assuming you are WebDeploy from VS to publish your site, I think the only way to force creating a folder is to have it on your client side. If you use kudu you can look at post deployment actions
I would suggest updating your code though to create the folder if it doesn't exist. That would make your code more robust and self contained rather than depending on a certain deployment mechanism to create the folder for you.

Resources