Saturday 28 July 2018

Azure App Service now supports Java SE on Linux

Lately there have been a whole lot of changes to Java and its vibrant communities. Now shared between Oracle for Java SE and Eclipse Foundation for Jakarta EE (formerly Java EE), Java continues to be the leading programming language by developers and enterprises. As a matter of fact, it is now well-positioned to thrive in the cloud considering how modern application development is trending with over 12 million Java developers worldwide, and digital transformation being top of mind for many IT organizations.

With the sheer volume of Java apps in existence and soon to be developed, Java developers will benefit greatly from cloud services that will enable fast and secure application development while saving time and cost. Couple this with a vast geographic region coverage, it is a cloud solution every developer should experience.

Today, Microsoft is pleased to announce that Azure App Service now supports Java SE 8 based applications on Linux, now available in public preview. This and subsequent time released versions will be supported for an extended period, as well as upcoming LTS versions. Java web apps can now be built and deployed on a highly scalable, self-patching web hosting service where bug fixes and security updates will be maintained by Microsoft. Additional performance features include scaling to support millions of users with multiple instances, applications, and regions in a dynamic scaling intelligent configuration.

Java Web Apps benefits


Let Azure App Service do all the heavy lifting commonly associated with enterprise-grade infrastructure so developers can focus on productivity. Take advantage of Microsoft Azure’s battle tested infrastructure platform spanning from global security compliance to DevOps capabilities. Developer productivity benefits do not stop there. Java web apps provide the following benefits:

◈ Fully managed enterprise platform – Log aggregation, email notifications, and Azure portal alerts. Version updates will soon include auto-patching.

◈ Performance monitoring – Integrate with the Application Performance Management (APM) product of your choice to monitor and manage applications.

◈ Global scale with high availability – 99.95% uptime with low latency, auto-scaling, or manual-scaling (up or out), anywhere in Microsoft’s global datacenters.

◈ Security and compliance – App Service is ISO, SOC, PCI, and GDPR compliant.
Authentication and authorization – Built-in authentication with Azure Active Directory, governance with Roll-Based Access Control (RBAC) to manage IP address restrictions.

◈ Build automation and CI/CD Support – Maven, Jenkins, and Visual Studio Team Services support will be available in the general availability release.

There are three ways of deploying Java Web Apps on Azure. You can create it from the Azure portal, use a template, or create and deploy from Maven. In this post, we will cover how to deploy a Spring Boot app using Maven.

Get started with Maven and Spring


To get started, clone your favorite Java Web app or use this sample: bash-3.2$ git clone

Add the Maven plugin for Azure Web Apps to the app project POM file and set server port to 80.

<build>
   <plugins>
      <plugin>
         <groupId>com.microsoft.azure</groupId>
         <artifactId>azure-webapp-maven-plugin</artifactId>
         <version>1.2.0</version>
         <configuration>

            <!-- Web App information -->
            <resourceGroup>${RESOURCE_GROUP}</resourceGroup>
            <appName>${WEBAPP_NAME}</appName>
            <region>${REGION}</region>
            <pricingTier>S1</pricingTier>

            <!-- Java Runtime Stack for Web App on Linux -->
            <linuxRuntime>jre8</linuxRuntime>

            <deploymentType>ftp</deploymentType>
            <!-- Resources to be deployed to your Web App -->
            <resources>
               <resource>
                  <directory>${project.basedir}/target</directory>
                  <targetPath>/</targetPath>
                  <includes>
                     <include>app.jar</include>
                  </includes>
               </resource>
            </resources>
            <appSettings>
               <property>
                  <name>JAVA_OPTS</name>
                  <value>-Djava.security.egd=file:/dev/./urandom</value>
               </property>
            </appSettings>
         </configuration>
     </plugin>
   </plugins>
   <finalName>app</finalName>
</build> ​

Build, package, and deploy using Maven – like you would normally do.

bash-3.2$ mvn package azure-webapp:deploy
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------------------------------------------------------
[INFO] Building petclinic 2.0.0
[INFO] ----------------------------------------------------------------------
[INFO]
...
...
[INFO] --- azure-webapp-maven-plugin:1.2.0:deploy (default-cli) @ spring-petclinic ---
[INFO] Start deploying to Web App myjavase-07262018aa...
[INFO] Authenticate with Azure CLI 2.0
[INFO] Target Web App doesn't exist. Creating a new one...
[INFO] Creating App Service Plan 'ServicePlan1af9c8f0-3f71-43a8'...
[INFO] Successfully created App Service Plan.
[INFO] Successfully created Web App.
...
...

[INFO] Finished uploading directory: /Users/selvasingh/GitHub/selvasingh/spring-petclinic/target/azure-webapps/myjavase-07262018aa --> /site/wwwroot
[INFO] Successfully uploaded files to FTP server: waws-prod-bay-081.ftp.azurewebsites.windows.net
[INFO] Starting Web App after deploying artifacts...
[INFO] Successfully started Web App.
[INFO] Successfully deployed Web App at https://myjavase-07262018aa.azurewebsites.net
[INFO] ----------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ----------------------------------------------------------------------
[INFO] Total time: 03:06 min
[INFO] Finished at: 2018-07-13T18:03:22-07:00
[INFO] Final Memory: 139M/987M
[INFO] ----------------------------------------------------------------------

Open the site in your favorite browser.

Azure Guides, Azure Learning, Azure Certification, Azure Tutorial and Material

And here it is, your first Java web app on Azure App Service. Nice job!

More friendly Java tools on the way


We understand that development tools are not one size fit all. We are making sure we continue to enrich our tool suite with tools that enhance productivity and efficiency. In the meantime, expect to see support for Gradle and Jenkins next.

Related Posts

0 comments:

Post a Comment