Java and Microsoft Cloud - Brief Essays

    Hi,

    What does it take to run my Java application in the Microsoft cloud? How much effort must be spent on the developer’s human hours in order to at least test the project and decide whether to migrate at all, or whether to wait or even postpone the move. This short article is designed to fill a micron-sized niche and take a quick look at today's Java Java-based Azure situation.
     

    Microsoft Azure has several options for launching 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 setting up JDK deployment scripts and application servers and packing the Java application into a Cloud Services container. It turned out to be an abstraction of what was invented for .NET for an application written using other principles - we take the Cloud Service container, write in the configuration files what and where lies, and the project is ready. This resulted in many inconveniences, including the most important thing - the need to manually configure several scripts - not all developers have the experience and desire to do this time-consuming task (the author has been doing this and since then has not had much desire to continue). In 2012, Microsoft Azure announced and, later, deployed to GA a new proposal - the implementation of IaaS: the developer takes the virtual machine, installs all the necessary software into it and makes all the related settings. The inconvenience is that, having gone from manually configuring 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 in which there is a division of labor - the administrator is responsible for setting up the web server, and the developer is developing. Now there are more and more people who are forced to combine these two roles and these people are not always happy and ready to do the work of ITPro. the developer takes the virtual machine, installs all the necessary software into it and makes all the related settings. The inconvenience is that, having gone from manually configuring 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 in which there is a division of labor - the administrator is responsible for setting up the web server, and the developer is developing. Now there are more and more people who are forced to combine these two roles and these people are not always happy and ready to do the work of ITPro. the developer takes the virtual machine, installs all the necessary software into it and makes all the related settings. The inconvenience is that, having gone from manually configuring 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 in which there is a division of labor - the administrator is responsible for setting up the web server, and the developer is developing. Now there are more and more people who are forced to combine these two roles and these people are not always happy and ready to do the work of ITPro. 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 in which there is a division of labor - the administrator is responsible for setting up the web server, and the developer is developing. Now there are more and more people who are forced to combine these two roles and these people are not always happy and ready to do the work of ITPro. 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 in which there is a division of labor - the administrator is responsible for setting up the web server, and the developer is developing. Now there are more and more people who are forced to combine these two roles and these people are not always happy and ready to do the work of ITPro.
     
    The turning point in the whole story was the development of the Microsoft Azure plugin for Eclipse. The plugin existed before, until 2012, but did not have functionality that greatly simplified the development process. With the new versions, the plugin has gained new features: now the developer does not need to worry about “setting up a couple more scripts and debugging them” (a long and time-consuming process in the case of complex deployments) - the process of setting up all scripts and the Cloud Service takes place 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 bootstrapper of a cloud service has grown into a full-fledged assistant, which is pleasant and easy to use.
     
    Using the plugin, you can perform actions such as launching a Java project in the Microsoft Azure emulator, deploying the project to the platform itself, Remote Desktop configuration, and much more. The plugin is free, as is the emulator, which makes it possible to test and debug the project 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 allows it. For example, a developer is free to use one of the fruits of a recent collaboration pact between Microsoft and Azul , which develops tools known for performance indicators.
     
    Azul continues to develop its own OpenJDK Zulu build, which is fully certified for use on Windows Server x64 (which means that it can be used without problems on Microsoft Azure). Zulu does not have any distinctive technical features - at the early stage of development, no optimizations or tunings specific to the cloud were applied to Zulu.
     

     
    We can’t ignore the fact that in 2013 a fairly quiet, but very important event took place - the partnership between Microsoft and Oracle. Now in Microsoft Azure, images are available that are prepared and verified 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 gives 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 using Microsoft Azure.
     
    After downloading and unpacking Eclipse, we will start the development environment and, having visited the update menu Help => Install New Software, we will enter the address of the repository - dl.msopentech.com/eclipse .

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

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

    Export the 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 created project will open. Indicate 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 it is not determined, then a mistake was made.
     

     
    On the last tab Applications you need to add the WAR-file. This project will be automatically deployed to the local Microsoft Azure computing emulator on the web server you specified. Now, if you click on the launch icon of the local emulator, 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 Third-party - as mentioned earlier, you can choose to implement Azul.
    After deploying the unit, you can open the site in a browser atlocalhost : 8080 / ProjectName .
    Now you can put it in the cloud. To do this, register a subscription to http : // azure . com .
    Click on Publish to Windows Azure Cloud .

     
    In the process, click Import from PUBLISH-SETTINGS file , select Import PUBLISH-SETTINGS File in Import Subscription Information and, when the browser window opens, enter the account information for which you signed up for Microsoft Azure, thereby downloading a special configuration file (instead of to configure everything manually.

     
    On the way, on the Remote Access tab , uncheck, thus disabling remote access to your role in this way, which is not necessary now, since this is connected with downloading the security certificate.
    We will wait until the role is deployed. During deployment, the entire process of installing your application occurs: free equipment is searched, the service is downloaded to the portal, a virtual machine is created and deployed, the service is loaded on it, after which the OnStartup and Run events are triggered - in the OnStartup event the web server and JDK are launched, necessary To execute our application, the main logic of the application occurs in the Run method event.
    Going to the page of our application on the Microsoft Azure management portal, we’ll pay attention to the properties panel on the right. The DNS name of the deployment is available in it. The URL looks like .cloudapp.net, where is some random identifier that is different from the address that the application will receive when deployed in a real environment. Although the deployment cells are separated from each other, there are no physical differences between them - everything is determined by where the load balancer is connected. Try following the link. In the event that you configured everything correctly, you should be shown the 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 directly, let's say:
    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 - maybe the DNS name is not ready yet. 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, which is discussed here .
    Summing up the results of this article, I note that back in the year before last, I had to admit in conversations at conferences and over the phone that from Java to Microsoft Azure, not everything is as wonderful as we would like, and this story requires close study and investment. Today everything is much simpler - I can demonstrate the entire history of Java and Microsoft Azure in fifteen minutes or give a link to an introduction on working with the plugin, because no presentation or demonstration can replace my own experience.
     
    Thanks.

    Sitelinks



    Also popular now: