I'm trying to edit my configuration app.config from the Azure WebJob. I currently have 2 web jobs that configured to run as on-demand (Cron Scheduled)
My Jobs are working perfectly fine. But When I try to view the source code of my web jobs through Kudo Command
https://xxxxx.scm.azurewebsites.net/DebugConsole
I'm not able to see any jobs for the trigger. In fact, there is no folder called triggered
but when I tried to https://xx.scm.azurewebsites.net/azurejobs/#/jobs I can able to see my Jobs there.
How to find the source code of my WebJobs?
The default location for WebJobs is under d:\home\site\wwwroot\App_Data\jobs. Did you look there?
Related
I want to run a console application and see the output. It's a continuous one; I don't understand the other one.
I've got VisualStudio to deploy a console app to a WebJob, but I absolutely cannot get any output from it.
EDIT: why does the app service get a URL to 'browse' it? It's not a website.
EDIT: under HostingPlan->AppService->Diagnostic settings if I try to create a new diagnostic settings then there is a checkbox called AppServiceConsoleLogs which sounds promising, but it seems to require an Archive to storage account and none is listed even though I've set on up.
If you really published this as a "WebJob," then go to the "WebJobs" section of your AppService -- it's in the Settings section -- and it should display your WebJob in the list. Then right-click on your job and select "Logs." This will open the logs for your job. Click on the "Toggle Output" button and this should show you anything your app wrote to the console.
Edit:
Here is the WebJobs section of an App Service on the Azure Portal. If you Right-click on a specific job, it will show a (non-browser) context menu that gives you access to Logs.
If you have a subscription to Azure DevOps, you will be able to run your console app. Upload your console app and create a pipeline to run a script. Add the command and necessary arguments if any and run the pipeline.
The process may take around 10~15 minutes if you do not have an account with azure DevOps, and less if you have it already. Please follow the steps mentioned in the blog I wrote here and you should be able to run your console app without trouble.
How to run Console Applications on Azure Pipelines
PS: This may not be the best solution but as of now it offers free run of console apps on Azure Pipelines. Hope this helps!
why does the app service get a URL to 'browse' it?
Suppose it's your azure web url cause webjob is host in a web, if not please provide more information.
it seems to require an Archive to storage account and none is listed
even though I've set on up.
Mostly it's because your storage account region is different from your web region, so create a new account with the same region then it will show in the list.
And suppose you want to check the webjob output, the simplest way is the Bryan Lewis way, just check the Logs in the kudu page. Else if you want to save it to storage and view it, go to App Service logs under your web Monitoring, set the Application Logging (Blob) and set the storage account(remember the region should be same or create a new one). Then you will be able to view the log csv file like below.
I'm struggling to understand how to run a powershell script (it just runs an exe) on the App Service after deployment using Azure Devops.
FYI - the exe just reads some config info in the web.config and does some database updates. So it needs access to the transformed web.config and the SQL Server database that the App Service has.
I've tried adding a Powershell step using a Release Pipeline deployment task, but it seems to only run on the Agent, which does not have the context that the exe needs.
I can run the script manually using the Kudu command line window tool, but I need to automate this thing.
I've seen a few SO articles like this: How to add a custom post deployment script to azure websites? or Kudu post-deployment commands not running but I think that only works when you use the inbuilt deployment mechanism for App Services. ie - I couldn't get it to trigger the script in post-deploy from Azure Devops.
This is in the comments above, but if people find it useful, the answer to this is
Using the Azure App Service Deploy task, expand Post Deployment Action, there's an option to run a script (or inline write one).
This will be executed as part of the app service deployment and should allow you to do what you want. It's run at the wwwroot folder so the files need to be present in your actual deployment (zip/folder).
I've added some webjobs to an appjob. The webjobs are deplayed from VS together with a new version of the webapp.
TO schedule the jobs I've added a settings.job file to the webjob rootfolder.
If I look in Azure the webjobs are scheduled correctly.
But how to change that schedule from Azure ? The only way to change that schedule now seem to be to change the settings.job file and redeploy from VS.
UPDATE:
given that KUDU does not always work and that the procedure to change the schedule is not really fit for a non-tech user. I started looking at using azure scheduler. But cannot find out how to get it working.
From the webapp|webjob configuration I took the webhookurl, usr, pwd.
Created a new schedule using this webhookurl and credentials (basic auth)
But I get this error:
No route registered for '/api/triggeredwebjobs/<webjobname>/run'
Any suggestions?
how to change settings.job schedule.
You could put the settings.job file at the root of WebJob directory and modify it, then redeploy your WebJob project.
You could leverage kudu, and navigate to D:\home\site\wwwroot\app_data\jobs\triggered\<job-name>, then modify the settings.job.
Moreover, you could use the WebJobs API for creating/updating the schedule for a triggered job, and it would automatically create/update the settings.job file for you.
PUT https://{webdeploy-username}:{password}#{your-webapp-name}.scm.azurewebsites.net/api/triggeredwebjobs/{webjob-name}/settings
Body: {"schedule": "*/30 * * * * *"}
I have checked my WebJob log on kudu, it would take some time for the modified schedule to take effort.
I started looking at using azure scheduler. But cannot find out how to get it working.
No route registered for '/api/triggeredwebjobs//run'
For Azure Scheduler, you could refer to David Ebbo's blog here. Based on your error, I assumed that your Http method is wrong, you should use POST. Here is my test, you could refer to it:
For those who struggle with the same issue :
Best solution turned out to be to use Azure's Scheduler Job Collections.
The tricky part was finding out how to set this up.
Action settings:
- https
- copy the uri you find in the properties page of the webjob to call, it is called 'webhook'
- copy the credentials from the same place
You can also access Kudu (Advanced Tools) at https://yoursite.scm.azurewebsites.net, and modify the settings.job file directly via the Console.
I would recommend you redeploy though so that you have the right schedules in your version control at all times. Otherwise you might publish and then realize you have the old schedules again.
Right. So this article: https://azure.microsoft.com/en-us/documentation/articles/web-sites-create-web-jobs/ mentions that you can "You can run programs or scripts in WebJobs in your App Service web app in three ways: on demand, continuously, or on a schedule. There is no additional cost to use WebJobs."
Which is great, the free-alternative is a Scheduler Job Collection
with a job, but you're limited to running it every hour. So being able to run the webjob as part of the webapp, and on a higher frequency is what we need.
However, I'm really struggling to find any way of automating this process. Using the Azure portal to add a web job works fine - but the "automation script" generation tool doesn't generate a json file which includes anything about the webjob - so we'd always have to manually create it.
There are examples of custom templates for automating the creation of webjobs - but they all create said webjob as part of a Scheduler Job Collection, where we are limited to the hourly execution.
To summarise: I'm looking for a way of automating the creation of a webjob, linked to a web-app (such that it doesn't incur extra costs).
Any help would be much appreciated.
WebJobs are deployed by folder convention (as described here), so deploying a WebJob is no different from deploying a Web App. It's simply a matter of getting the files in the right place.
Specifically, triggered WebJobs (manual or scheduled) go under site\wwwroot\app_data\jobs\triggered\{job name} and continuous WebJobs go under site\wwwroot\app_data\jobs\continuous\{job name}.
I'm trying to deploy a scheduled webjob through CI and vNext tasks in VSO.
I followed the steps in the following tutorial to deploy a webjob along with a web app ("Enable automatic deployment with a web project"):
https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/
I succeeded partially: the webjob gets deployed along with the web application. However, it is marked as On Demand instead of Scheduled (or whatever the proper status is). I can run the webjob manually and it runs just fine. I checked the files webjob-publish-settings.json (in the webjob) and webjobs-list.json (in the web app) and they seem to be alright, judging from the tutorial.
Am I missing anything? Thank you.
You can use the cron expression to create the webjob scheduler if your app is running in Basic or High mode. Refer to this link for details: Create a scheduled WebJob using a CRON expression
Otherwise, you need to enable continues delivery of Azure Webjobs.
More reference: Deploy your WebJobs projects with your Azure website using continuous delivery