How do I automatically launch Azure Function in a local environment? - java

I have two Azure functions linked together. I want to test them locally using Rest Assured. But to do this, I have to manually run them every time before the tests. Is there any way to automate this moment? So that when the test starts, the service starts automatically.

You would have to include a step to start your application (function app) using Azure Functions Core CLI. If you do not have that already you have to set it up: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash%2Ckeda.
To start your application with command line you can use func host start. Posting a documentation for reference: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=v4%2Cwindows%2Ccsharp%2Cportal%2Cbash%2Ckeda#start.

Related

Can AWS Lambda execute Spring Boot application implemented using command line runner?

My spring boot application implemented using command line runner (meaning it's not an API) is executed using java -jar with bunch of command line arguments. We have been running our application manually on AWS EC2 so far and now in an attempt to Automate application execution we have started a POC using Lambda. Lambda is chosen because application must trigger at SNS event (which is for file upload event in S3).
I have configured lambda function using Java runtime and attached it to SNS topic. Lambda is successfully triggered and sending a call to my application Jar which is uploaded in lambda function through S3.
Application first step is to download the file from S3, so I am implementing LambdaHandler class using S3 event, as shown below.
public class LambdaHandler implements RequestHandler<S3Event, String> {
// Code to fetch S3 object name here which is needed in application processing logic further
}
I am unable to figure out how to initialize spring boot batch application which is implemented using command line runner, is this even possible?
Would you recommend an alternate approach (Jenkins connecting to EC2 and running a bash script to download file from S3 then wget jar file from artifactory and run java -jar build command to execute)

Run a simple Java program in the OpenShift cloud

what is the easiest method to run a Java program inside a gear on OpenShift?
I don't need a complex framework or web server. I just need a container to which I can upload my Java Files, compile and execute them in the cloud. The application I have in mind is very simple, a program that gathers some information and that I can connect to via RMI and just ask for the data.
Thanks.
If you don't need an application server you'd better take a look at DIY cartridge. You'd just have to create it from your code:
rhc app-create yourapp diy-0.1 --from-code git://github.com/(...).git
You could even use git hooks to launch it. Take a look at the hooks I use at my Wedding Tables Planner web, based in this template.
I think easiest is tu run a jbossas app and stop the jbossas cart if necessary. Otherwise you may play with the diy app type.

Java Code in Azure cloud service

I have java code (that generates jasper reports) and I couldn't convert it to .net and I want to run it on a "Cloud Services" how can I run java code into cloud service ?
any help will be appreciated
#Dhana provided a link to a tutorial for pushing a Java app to Azure in Cloud Services (worker role). You could also push to a Web role but it makes less sense since IIS runs in a Web role, and you'll probably want Jetty, Tomcat, or JBoss for your web server.
If you're running a console app, that's fine too - just launch it from a startup script or the OnStart() in your workerrole.cs.
You'll need to install the tooling into Eclipse. At this point, you'll be able to build Azure deployment packages, in a similar way to Visual Studio (The Azure plugin for Eclipse only works on Windows though). Part of the packaging sets up links to the appropriate JVM and web server package, as well as your own jar files.
If, say, you have a console app that listens on a port, you'll just need to make sure you have an input endpoint set up for the port you want to expose.

How can I start a java program by sending an email

We are working on a project and Im involved in continuous integration testing.
I need to
deploy the new project code on a staging server, not using Jenkins, but ftp;
after the deploy an email is sent to indicate successfull deploy and we need it to start my integration tests;
integration tests, if successfull, will start a deploy on integration server.
I am going to write a java program that will login to Jenkins and execute the integration tests.
Question is: how can the email message activate the java program?
EDIT: Normally, jenkins offers a feature that starts a job after getting an email, but we are having a security problem with that
Make a program or script which will peridically poll a mail server box and upon getting an appropirate email will run another java program.
Please read Jenkins documentation thoroughly. If you are using a version control system, Jenkins can automatically pull the code and run test cases on it. You can notify Jenkins using various methods... including webhooks.
Do go through various plugins for Jenkins.
Update:
I have not used this myself. But looks like this is what you want: Mail Commander Plugin
And the command you send can be something like this:
curl --data '' http://<server>:<port>/job/<projectname>/build

Mount Java app inside cucumber rails app

I have a rails app that talks to an api running on the same domain via ajax calls. I want to test this app using cucumber. The api is written in java and packaged as a jar. How can I mount the jar when using cucumber?
There is no way to do it automatically but you can add Before hook into env.rb or put it into separate file and in this method you can load your java extension by issuing shell command, you can store process pid in variable and kill this process in After callbalk. You can configure Capybara to start server on specific port and I think you can tune your application to use specific port too.

Categories