📜 ⬆️ ⬇️

Java and Microsoft Cloud - Brief Essays

Hello,

What do you need to run your Java application in the Microsoft cloud? How much effort must be spent on the developer’s man-hours in order to at least test the project and decide whether to migrate it at all, or whether to wait or postpone the move altogether. This short article aims to fill a micron size niche and make a brief insight into the current Java situation on Microsoft Azure.


In Microsoft Azure, there are several options for running Java applications. Until 2012, when the platform contained a full-fledged implementation of only one delivery model (PaaS), the developer could launch a Java application by manually configuring the deployment scripts for the JDK and the application server and packaging the Java application into the Cloud Services container. It was an abstraction of what was invented for .NET, for an application written using other principles - we take the Cloud Service container, write it in the configuration files, where it is, and the project is ready. This resulted in many inconveniences, including the most important thing - the need to manually set up several scripts - not all developers have the experience and desire to do this time-consuming task (the author has done this and has not had a great desire to continue since). In 2012, Microsoft Azure announced and, later, deployed a new proposal to GA - IaaS implementation: a developer takes a virtual machine, installs all the necessary software in it, and makes all the associated settings. The disadvantage is that, having gone from manually setting up configuration scripts, the developers came to the need to manually configure the web server in a virtual machine. Conceptually - a serious step. Practically - a step, often unnecessary. This option is convenient for companies where there is a division of labor - the administrator is setting up the web server, the developer is developing. Now, more and more people who are forced to combine these two roles and these people are not always satisfied and ready to engage in the work of ITPro.
')
The development of the Microsoft Azure plugin for Eclipse was a turning point in the whole story. The plug-in existed before, until 2012, but did not have functionality that significantly simplifies the development process. With the new versions, the plugin is overgrown with new features: now the developer does not need to worry about “setting up a couple more scripts and deciding on them” (a long and laborious process in case of complex deployments) - the process of setting up all scripts and Cloud Service occurs in the background, as the developer indicates which application server to use, which version of the JDK, which Java applications to deploy to the application server, and so on. The plugin from a simple cloud service bootstrapper has grown into a full-fledged assistant, which is nice and easy to use. Despite the positioning of Java as the first class citizen programming language on the platform, only from the moment we receive a convenient means of automating routine actions, we can say that yes, you can deploy a Java application to Microsoft Azure, and this process does not cause torment with writing scripts for each application server .

Using the plugin, you can perform actions such as launching a Java project in a Microsoft Azure emulator, deploying a project to the platform itself, configuring Remote Desktop, and more. The plugin is free, as is the emulator, which makes it possible to test and debug the project even before the stage of purchasing Microsoft Azure services, which is very convenient for companies that are only evaluating what is happening.



As for the JDK distributions, you can use any distribution if its license permits. For example, a developer is free to use one of the fruits of the recent Microsoft- Azul collaboration pact, which develops well-known productivity tools.

Azul continues to develop its own build of the OpenJDK Zulu, which is fully certified to use for Windows Server x64 (which means that it can be used without any problems on Microsoft Azure). Zulu does not have any distinctive features in technical terms - at the early development stage, no cloud-specific optimizations or tunings were used for Zulu.



You can not get around the fact that in 2013 there was a fairly quiet, but very important event - the partnership of Microsoft and Oracle. Now in Microsoft Azure, images are available that are prepared and tested by Oracle and include both Linux distributions and images with pre-installed servers and Java.

In 2014, Java support was announced on Microsoft Azure Web Sites - that is, you already have everything out of the box, and you can immediately deploy a website instead of the settings described below. However, the approach described below provides more flexibility and uses another platform service, Cloud Services, used to deploy complex applications.

Let's welcome the world from a Java application developed in Eclipse and using Microsoft Azure.

After downloading and unpacking Eclipse, launch the development environment and, having visited the Help => Install New Software update menu , enter the repository address - dl.msopentech.com/eclipse .

In the lower window after loading the repository contents list, a drop-down “branch” of Windows Azure Toolkit For Java will appear . This branch contains several projects - Microsoft JDBC Driver for SQL Server (for working with the repository, including SQL Azure Databases) and others. Note the entire thread.
During the installation process, we agree with the license agreement and restart the IDE.
Create a Dynamic Web Project .


The main folder that interests us is WebContent . We will put the main JSP file in it. Create it from the JSP File template => New JSP File (html) and copy the code.
Hey azure

Export project to WAR - Export => WAR File .
Let's create a project for Microsoft Azure, the template of which appears after installing the plugin.


The settings window for the project being created will open. Specify the JDK and server - on the server tab when specifying a folder with, for example, Apache Tomcat, the server name should be determined automatically. If not determined, it means that an error was made.



On the last tab of the Applications you need to add a WAR file. This project will be automatically deployed to the local Microsoft Azure Computing Emulator on your web server. Now, if you click on the local emulator launch icon, it will be launched with all the software infrastructure packaged in the deployment unit - it will contain the JDK, the web server, and the application.
If you do not want to use your JDK, you can specify the Third-party - as mentioned earlier, you can choose the implementation of Azul.
After the unit has been deployed, you can open the site in a browser at localhost : 8080 / ProjectName .
Now you can put the resulting in the cloud. To do this, you must register a subscription to http : // azure . com .
Click on Publish to Windows Azure Cloud .


In the process, click Import from PUBLISH-SETTINGS file , select Download PUBLISH-SETTINGS File in Import Subscription Information and, when the browser window opens, enter the account data for which the Microsoft Azure subscription is registered, thereby downloading a special configuration file (instead of to customize everything manually.


Along the way, on the Remote Access tab, uncheck this box, thus turning off remote access to your role, which is not necessary now, as this is related to downloading the security certificate.
Let's wait for the deployment of the role. During the deployment, the entire installation process of your application takes place: free hardware is searched, the service is loaded onto the portal, the virtual machine is created and deployed, the service is loaded onto it, and the OnStartup and Run events are triggered - in the OnStartup event, the web server and the JDK are started To execute our application, the main logic of the application occurs in the Run event method.
Turning to the page of our application on the Microsoft Azure Management Portal, we turn our attention to the properties panel on the right. It has a DNS deployment name available. The URL looks like .cloudapp.net, where is some random identifier different from the address that the application will receive when deployed in a real environment. Although the deployment cells are divided between each other, there are no physical differences between them — everything is determined by where the load balancer is connected. Try to follow the link. In the event that you have configured everything correctly, you should see a page of your site. If the Tomcat admin panel window appears, try adding the name of your application to the link and specifying the file name itself, for example:
fe744ac908e24c4dafbc2afce3c7f5da.cloudapp.net/JavaWindowsAzure/Index.jsp
Note : If you get a 404 DNS error when entering the site, wait a couple of minutes and try again - perhaps the DNS name is not yet ready. Microsoft Azure creates DNS names dynamically and applying these changes can take several minutes.
That's all.
However, you can go an even simpler way and create a website using Web Sites services, which is discussed here .
Summing up this article, I note that even the year before last I had to admit in conversations at conferences and by phone that with Java on Microsoft Azure, not everything is as wonderful as we would like, and this story requires close study and investment. Today everything is much simpler - in fifteen minutes I can demonstrate the whole history of Java and Microsoft Azure or give a link to the introduction to working with the plugin, because no presentation or demonstration will replace my own experience.

Thank.

Additional links


Source: https://habr.com/ru/post/234095/


All Articles