Make scheduled call on Azure with webjobs - node.js

I have a nodejs application deployed on Azure and I want to make a call to it let's say every friday.
Can I upload a .bat file to the webjob and tell it to call app.azurewebsites.net/test ?
Is it possible this way or is it more complex than this?
Thank you,
Mihai Dobrescu

Update:
If you just want to call the website from webjobs, it's possible. Otherwise, you can ignore my answer.
I'm not familiar with .bat, here is an link Azure WebJob calling a Web Page using Powershell. You can modify to .bat in the same way.
Please correct me if I misunderstand you.
If you just want to call the site url deployed in azure every Friday, you can just write some code to call the website(.bat / powershell / .net etc.) as webjobs, then set the schedule as per the Cron Expression(the site is broken now, please refer to this one).
If call every Friday at 9:00, the schedule like below:
0 0 9 * * Fri

When it comes to Azure WebJobs, it is actually a background app. It is not supposed to accept an incoming request just like that. However, it makes sense to post some data to a Azure queue/table record and have the WebJob or anything else read it to take suitable action. If you explain in more detail, I can help more.
Not to complicate stuff, but Azure functions also help a lot in scenarios like these.

Related

how to perform background jobs in azure

I am new to azure.
I want to run some background process on schedule interval in azure.
for example i have sample web app that send test mail.how can I runthat on every 10 minutes in azure.
i read about webjobs and how can i schedule them. I tried also creating aconsole app and uploading .exe. it runs but gets filed.
I dont know how i can upload web app also as web job same as I did for exe??
or need to opt for another option like worker role..
I m totally new to it.. so please guys suggest what would be suitable for my requirement.
I will go through it .
EDIT:
Sending mail is not my requirement. i m just doing that to check is my web job running succesfully at scheduled time interval or not.
but as i m getting unexpected response i think i should write some other code like write textfile azure storage account at every minute..
as i m totaly new.. dont have any idea about that ..anyone can share me any good link or sample demo if you can.please.
Here are two ways to develop a web job.
First
Upload a zip file that contains your executable or script file as well as any supporting files needed to run the program or script. The supported executable or script file types are listed as below.
For example, if you want to use a console application as the web job, we can go to the [ApplicationSolutionFolder/bin] and compress the Release or Debug folder as an zip file(It's better to use Release folder), then upload this zip file to azure as the web job.
Second:
We can develop it via Visual Studio: Deploy a WebJobs project
Update:
As you want to run every 10 minutes, we can set the triggers as scheduled and set the CRON expressions as [0 */10 * * * *] when we upload our zip file.
More information about CRON expressions, we can refer to: CRON expressions

Azure WebJob-Project - access parent project artifacts

I am new to Azure WebJobs. For a mobile app we need some WebJobs that can run scheduled. My question is about the "Projects-Architecture" when it comes to WebJobs.
As far as i know, a new project is created for every WebJob. I am doing this by righclicking the main project -> add new azure webjob project.
But how are these projects "combined". There should be some reference to the parent project that i cannot find. I need to access the entities from the main project inside the WebJob. How should this be done?
Furthermore i am not sure wheter to implement Logic+Data access directly inside the WebJob or let the WebJob instead call another Controller to handle this?
Documentation on this is horrible, every help would be great.
They are not really "combined". There is a reference in the Web App (the webjobs-list.json) in properties that tells VS to publish the webjob when you publish the web app. If you need to access entity models in the webjob, then you need to add a reference to your other projects just like you would in any other project (add the project reference and then add a using statement in the webjob). The reference will get compiled into the webjob.
May I ask what are you trying to achieve via the web job? this would help in identifying why the need for accessing the models of your MVC app.
One suggestion would be to push the object from the MVC app to an azure queue and then access it via your job. Set it up in a way to identify new messages in a queue. (trigger). - not sure if this helps cause I am not sure how quick the web job is run and what are the other constraints you are working with.
When you add a new or existing WebJob Project to your solution, Visual Studio will take care of this for you. It is not something new, as if you are adding a console/windows service project to your web/MVC application.
If you need these projects to communicate, you till need to add references to your other projects just like you would in any other project which will in turn get compiled.
If you need to learn more and check some examples, this tutorial https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk-get-started/ shows how to write code for a simple multi-tier ASP.NET MVC 5 application that uses the WebJobs SDK. Maybe that can give you some information on how to architect the application.

Azure website node process lifecycle

I 've found out that Azure websites (trial version) doesn't autostart my node sever process (it starts only when I load the url in the web browser); and that when there are no requests in a while, the process is killed.
I mean, when I git push my server, I would like it to start running immediately and continuously.
I read (here, for example) that this might have to do with the way iisnode manages azure websites, and that I can't do anything to change it. Is this the actual way Azure websites work? Is there any way I can deal with this?
Thanks in advance,
Bruno.
You've find the answer. There is no other answer.
The process termination because of inactivity comes from IIS - there is Idle Timeout setting. Which to my knowledge is not configurable in Azure Web Sites (at least not Free tier). Check out also this SO question and its answer to get better understanding on why you can't change this timeout on the FREE and STANDARD tiers.
And here is an interesting workaround to avoid this idle timeout. Actually if you use technique, you will also have kind-of "auto start", in terms that when your scheduler hits your site after a new deployment, it will "boot up".
This can get a little complicated, but if you don't want to use their 5-min ping service, you can keep these always on by doing the following:
Create an app setting on your website configuration tab within the portal:
WEBSITE_PRIVATE_EXTENSIONS and give it a value of 1
Create a text file named applicationhost.xdt and populate it with:
<?xml version="1.0"?><configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"><system.applicationHost><applicationPools><add name="DefaultAppPool" managedRuntimeVersion="v4.5" startMode="AlwaysRunning"><processModel identityType="ApplicationPoolIdentity" /></add></applicationPools></system.applicationHost></configuration>
ftp into your website and create a folder on the root directory called Site Extensions. (there should now be 3 folders in your root: LogFiles, site, & SiteExtensions)
Create another folder within 'Site Extensions', named ASPLimits
Upload the applicationhost.xdt into the ASPLimits folder
Restart your website using the portal

how long does it take to create an Azure Cloud Service? How to view log information?

I'm brand new to Azure. I'm trying to get a Cloud Service running with 3 web roles.
Last night I created the .cspkg and .cscfg files, exported the certificates and uploaded everything to Azure manager. The manager said my Cloud Service was successful, however for the last 10 hours when I click on "Cloud Services" in the manager it shows my service, but it says "Creating" with wait gif under "SERVICE STATUS".
Is it really still creating? Or did it fail? Is it possible to view more detailed information about the creation process and/or any log files?
Thanks,
Something "bad" has happened. Service Spin up time should be at most a few minutes.
I've seen it take up to 10-15 minutes depending on the hosting center and the number of scaled instances that need to come up but 10 hrs something has definitely gone wrong.
I would delete the service and start again. If you experience the same problem, have a look in your service start up code and make sure that there's no exceptions/infinite loops, other problems in there that might be causing problems.
It may miss any assembly references. If you included any assembly references(packages that are not part of .net) then please ensure that its copy to local attribute is set to true.

Difference in output on Azure

I've run into a little problem here. What I get on my local environment and my cloud result is different... I've tried using IntelliTrace, but everytime I want to debug a track it gives me a No source available message.
There aren't any exceptions or anything like that, everything loads perfectly fine... it just seems like the 4th case of the switch-case is screwed. I'm using 4 const ints in a static Common.cs file to populate these 4 possibilities; I know I could be using an enum, but it shouldn't really matter, right?
If this helps, I am also using Telerik's RadChart control. In other words, these 4 options manipulate the data in 4 different ways. People have told me that there is no way to debug code hosted within Azure, and that I could probably use Azure Diagnostics and keep tracing every few lines or so...
Does anyone have any pointers on which direction I should go? or have faced similar problems before? Many thanks... I am pretty much clueless in here.
EDIT: The problem lay with the localization on Azure. On my local machine the date format is dd/mm/yyyy, whereas on Azure it is mm/dd/yyyy. Hence, the problem arose...
It seems to me you're using a web role. If that's the case, the quickest way to explore differences between local deployment and azure deployment is to enable Web Deploy on your cloud project.
Once you've done that, use the Publish option on the Web project (NOT on the cloud project) to quickly upload your code changes to Azure, and explore doing old-fashioned Response.Write.
Ugly, but quite efficient when you don't get what's happening.
Pierre

Resources