Deploying a War file to Azure [duplicate] - java

This question already has an answer here:
Deploying WAR FILE in Microsoft Azure Web App
(1 answer)
Closed 5 years ago.
I am attempting to upload a War file of a web service to Azure, running tomcat 8.
I have the war file in the relevant webapps folder on onedrive, however the deployment consistently fails, and frustratingly it does so without an error message.
I'm pretty sure that if I can't use a method involving uploading the binary file to Azure, I cannot use Azure. When using repositories like github, the build would fail due to reference issues, so I believe that is not an option.
Unfortunately I must use Azure, I'm aware that with other services like AWS I'd be done in 5 minutes as you can directly upload without any Microsoft (tm) hassle.

Normally, there are 4 ways to deploy a war file on Azure Web Apps: FTP, repository like Github/BitBucket or OneDrive/Dropbox, Kudu Tool, Azure Toolkit for Eclipse/IntelliJ.
First of all, you need to know File structure on azure. The Java war file must be deployed at the directory webapps under the wwwroot path of Azure Web Apps. You can access the Kudu tool url https://<your-webapp-name>.scm.azurewebsites.net/DebugConsole to lookup it.
Using FTP for deployment, you can refer to the Kudu wiki page Accessing files via ftp to know it, and set the FTP user & password via Azure portal as below.
Using repository like GitHub, you can refer to the Kudu wiki page Deploying from GitHub to know it. Please first make sure the file structure on GitHub repository as the same as its under your wwwroot directory, as below.
A convenient and fast way is using Kudu tool to drag & drop your war file into the webapps directory, as below.
If you had installed Azure Toolkit for Eclipse/IntelliJ, you can refer to Deploy Java Web Apps to Azure using Eclipse or IntelliJ: Deploy Java Web Apps to Azure to do it.
Hope it helps. Any concern, please feel free to let me know.

Quick note that gave me a lot of frustration to figure out. If you use ftp via a client (I use FileZilla for it), think about this:
Place the .war file under: site > wwwroot > webapps > [Place .war file here].
Do also change the .war file name to: ROOT.war
It has to be that name for the system to deploy it. At least for me, the GitHub integration is not working, so I use this ftp method.
The deployment via ftp can take several minutes to be deployed and running.

Related

Securing subdirectory in Tomcat

So a bit of background I have a surface level understanding about Tomcat WAR/Java files but I am helping out the programming team as I am taking over managing our Linux servers.
We are utilizing Apache Tomcat 8.5 and we currently have a WAR file that has a database login xml file. We would like to pull out the xml file into its own directory but I want to secure it down to make sure it can only be accessed from the WAR files on the server and not directly by url.
(edit) XML outside of a war file not from within
I'm open to any idea and any form of implementation.

Gradle Spring Boot Rest Service Application Deployment in Azure

I have been working on SpringBoot with Gradle tool. I am able to deploy the application locally. When I am trying to deploy using Microsoft Azure through GitHub the application got deployed. But I am not able to trigger the application services.
It means when I am trying to hit my REST service or Swagger page which is in application I am getting 404 error message on browser. I was able deploy the same using Heroku.
Note: I am new to Microsoft Azure. I have followed few Stack Overflow pages and Azure videos and Documents. But none of them were very helpful.
Per my experience, there are two ways for packaging a spring boot application, as an executable jar or a war file. I don't know which one is your choice.
If you packaged as an executable jar to deploy it on Azure WebApp, you need to create a web.xml file at the path wwwroot, and follow the document Upload a custom Java web app to Azure to configure it. The key configuration is for the attribute processPath with the value like java -jar <your spring boot executable jar file name>.jar.
If you packaged as a war file to deploy it on Azure WebApp, it's simple that you just need to refer to the document Add a Java application to Azure App Service Web Apps to upload the war file to the related directory webapps. However, if you didn't configure Azure WebApp with Java runtime, you also need to configure your Azure webapp instance on Azure portal or create a web.xml file to configure it as below.
Hope it helps.

How Does One Deploy a Jersey Application to a Remote Tomcat Server

I need to state up front that I am not a Java developer. So it is fair to assume that I know very little about the tooling etc. that Java dev's will be naturally familiar with.
So, I have created a Jersey web api (2.25.1) on my home server running Windows 2012. It serves data to a Xamarin application. I need to deploy this to a Linux server (Ubuntu) on AWS which my friend spun up.
At the moment, the only access I have is via SSH (Putty).
Tomcat (and Glassfish) have been installed on the Linux machine.
How do I go about deploying that application to that AWS server?
The official Jersey documentation seems to be MIA, and my Googling efforts don't yield much. There's a lot of SO questions with a similar title to this one. But I have not found any of the answers (and in many cases, questions) helpful to my cause.
Cheers
I assume that you are using maven to create your jersey web app .
Upon build you will get a *.war file .Copy the same to tomcat/webapps folder .
Start your tomcat then.
To take your file there on remote use winscp tool with your ssh credentials.

Java Web Application Deployment

I am trying to deploy my java web application to Azure using FTP. Is the .war file enough to be uploaded? Or all the project files have to be uploaded?
I believe that .war file is enough, because in that file you have everything that your java web application need, like the java classes, servlets, static web pages, etc, as you can see in this example, opening the war file:
war file
In fact, when we use, for example, the Tomcat server, that's the only thing that the server use for running the web application.
I hope I have helped you!

How to deploy a Eclipse Java Web Dynamic Project on Amazon EC2?

I'm trying to create a web project that is able to communicate with Amazon RDS. I know how to make a localhost project connect to a RDS with JDBC.
However, the problem is that I never tried to deploy my project (so that, for example someone can type somePage.com, and go to my webpage).
I have an Amazon EC2 instance, and I've already written a simple hello world jsp page. I am able to compile it and run the Eclipse Web Dynamic Project using the installed Apache Tomcat Server, and then typing localhost:8080/somePage then I can see my hello world popping up.
However, how do I deploy my project on this EC2 instance? I'm using Windows Server 2012 edition.
My whole idea is that once I have one AMI image all setup, then I can just use autoscale to scale my webpage with that AMI image.
Can anyone point me to the right direction?
Follow the steps below:
Setup Apache Tomcat on your Amazon EC2 instance.
Usually all you have to do is download the current version, unzip it, and start it by running apache-tomcat-folder\bin\startup.bat. (You can also donwload an installer and set it up as windows service. Check this link for more details).
Make sure you test it before continuing (open its address on a browser, something like http://yourinstaceaddress.com:8080/).
Export your web application .war file
In Eclipse, right click on a Web project and select Export. Then select WAR file in the Export window and then select Next. Choose the project, the .war file name and folder to export. More detailed explanation can be found here and here (with pictures).
Deploy the .war file to your Tomcat Server
The, by far, simplest way to do this is to place your .war (say myapp.war) file in your apache-tomcat-folder\webapps\ folder.
There are other ways, like via Tomcat Manager. But they can be tricky and, as a new user, you should avoid them. (Don't worry: the simple method is ok for production deployment).
Test your web app
Visit the url: say your .war's name was myapp.war. You should visit http://yourinstaceaddress.com:8080/myapp
That's it. If you ever edit the app, repeat steps 2-4 (but delete the webapps\myapp\ folder created before executing step 3).
Boxfuse does exactly what you want.
For you Java web application you literally only have to execute:
boxfuse create my-tomcat-app -apptype=load-balanced
boxfuse scale my-tomcat-app -capacity=1-16:t2-micro:cpu25-75
boxfuse run my-tomcat-app-1.0.war -env=prod
This will
Configure your application to use an ELB
Set it to autoscale between 1 and 16 t2.micro instances based on CPU usage (scale in at 25% and below, scale out at 75% and above)
Create AMI containg Tomcat and your application ready to boot
Create an ELB
Create a security group with the correct ports
Create an auto-scaling group
Launch your instance(s)
Any subsequent update will be done as a zero downtime blue/green deployment.
For your domain, you can simply map your samepage.com DNS record to the CNAME of the ELB.
More info: https://boxfuse.com/blog/auto-scaling

Categories

Resources