Quantcast
Channel: SCN : All Content - SAP HANA Cloud Platform Developer Center
Viewing all articles
Browse latest Browse all 3285

Shortest way to taste the cloud (5 minute tutorial)

$
0
0

If you just create your account  and wondering what is the fastest way to see something running on the cloud, then you are on the right place!

 

So, we look for faster possible (hopefully automated) way to execute following steps:

  1. Get tools and SDK
  2. Create an application
  3. Compile and package it
  4. Deploy it
  5. Start it
  6. Access it

 

Ok, now we have a plan let see how we can automate as much as possible of those tasks.

 

Let assume that you already have Java installed.

 

As we want to automate we will need some tools for task automation. I prefer maven and hope you too. The tool is really powerful and installation is very simple.

In short - download it, unpack it, export in environment M2_HOME variable to point to folder where you unpack maven and in addition add M2_HOME/bin to your path variable:

export M2_HOME=<path to folded with unpacked maven>/maven

export PATH=${M2_HOME}/bin:${PATH}

 

We can use the maven templating toolkit and specifically the archetype for web applications “maven-archetype-webapp” to fully generate the simple "hello world” web application.

 

About other task automation we will look what our cloud experts say in SCN.

In this articleVedran Lerenc explains how we can use maven for SDK installation, application packaging and deployment on the cloud.

And in this exampleStephan Merker gives more complex scenario, by covering other application life cycle operations as start/stop and undeploy.

 

Now we have the knowledge and  can proceed with automation of all steps from our plan.

The expectations are that the whole scenario from beginning to the end would take us less that 5 minutes (including a little more than 1 minute waiting for application to start on the cloud before accessing it )

 

 

Step1 - Application generation

Create an empty folder for this experiment and execute following command:

mvn archetype:generate -DgroupId=com.acme.hello -DartifactId=com.acme.hello.webapp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false

 

GenerateProject.png

 

Step 2 - Build, Package, Stop (in case it was already started), Deploy, Start

All those steps will became a part of pom.xml file that was generated for us in Step 1.

Open the pom.xml file and add inside following content:

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">

     <modelVersion>4.0.0</modelVersion>

     <groupId>com.acme.hello</groupId>

     <artifactId>com.acme.hello.webapp</artifactId>

     <packaging>war</packaging>

     <version>1.0-SNAPSHOT</version>

     <name>com.acme.hello.webapp Maven Webapp</name>

     <url>http://maven.apache.org</url>

     <dependencies>

          <dependency>

               <groupId>junit</groupId>

               <artifactId>junit</artifactId>

               <version>3.8.1</version>

               <scope>test</scope>

          </dependency>

          <dependency>

               <groupId>com.sap.cloud</groupId>

               <artifactId>neo-java-web-api</artifactId>

               <version>${sdk.version}</version>

               <scope>provided</scope>

          </dependency>

     </dependencies>

     <build>

          <finalName>com.acme.hello.webapp</finalName>

          <plugins>

               <plugin>

                    <groupId>com.sap.cloud</groupId>

                    <artifactId>neo-java-web-maven-plugin</artifactId>

                    <version>${sdk.version}</version>

                    <executions>

                         <execution>

                              <phase>install</phase>

                              <goals>

                                   <goal>install-sdk</goal>

                                   <goal>stop</goal>

                                   <goal>deploy</goal>

                                   <goal>start</goal>

                              </goals>

                              <configuration>

                                   <sdkInstallPath>${project.build.directory}/sdk</sdkInstallPath>

                                   <host>${sap.cloud.host}</host>

                                   <user>${sap.cloud.username}</user>

                                   <password>${sap.cloud.password}</password>

                                   <account>${sap.cloud.account}</account>

                                   <application>${sap.cloud.application}</application>

                                   <source>${project.build.directory}/${project.artifactId}.war</source>

                                   <synchronous>true</synchronous>

                                

                                   <!-- proxy related information - if not behind proxy remove next 4 lines -->

                                   <consoleHttpProxyHost>${proxy.host}</consoleHttpProxyHost>

                                   <consoleHttpProxyPort>${proxy.port}</consoleHttpProxyPort>

                                   <consoleHttpsProxyHost>${proxy.host}</consoleHttpsProxyHost>

                                   <consoleHttpsProxyPort>${proxy.port}</consoleHttpsProxyPort>

                              </configuration>

                         </execution>

                    </executions>

               </plugin>

          </plugins>

     </build>

     <properties>

          <sdk.version>2.11.3</sdk.version>  

          <sap.cloud.host>hanatrial.ondemand.com</sap.cloud.host>

          <sap.cloud.application>hellomaven</sap.cloud.application>

       

          <!-- you need to fill your account information here -->

          <sap.cloud.account>account_name_here</sap.cloud.account>

          <sap.cloud.username>user_name_here</sap.cloud.username>

          <sap.cloud.password>password_here</sap.cloud.password>

       

          <!-- proxy related information here - if not behind proxy remove next 2 lines -->

          <proxy.host>proxy_host_here</proxy.host>

          <proxy.port>proxy_port_here</proxy.port>

     </properties>

</project>


Fill the account information and proxy settings inside properties. Keep in mind that this is not secure at all, but it is the faster approach .

 

If you want to make this secure and use it as part of continuous integration process (jenkins) you should use environment variables as they are used here.

 

When you are finish with editing the file, save it and execute following:

cd com.acme.hello.webapp/

mvn clean install

 

StartMVNBuild.png

When you get this result:

EndMVNBuild.png

 

This means the application is now started on the cloud.

Let go and see it.

 

Step 3 - Access it

Open the cockpit in your browser (https://account.hanatrial.ondemand.com/) and look for application “hellomaven” there:

AppInCockpit.png

 

Then open the link inside Application URLs section and you will get this:

ExecutedApp.png

 

And we are done!

 

Let check the times

1. Generation of application took around 16 sec

2. Edition of pom.xml file took less than 1 minute

3. Build, package, deploy and install took around 1 minute and 17 seconds

4. Accessing the application took less than 1 minute

 

So from nothing to the cloud in less than 4 minutes (around 3 minutes and 33 seconds)


I dare you to beat this result

 

Enjoy,

Dobri


Viewing all articles
Browse latest Browse all 3285

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>