Successfully reported this slideshow.
Your SlideShare is downloading. ×

Build a Java Web Application using Azure Cosmos DB and the SQL API

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 14 Ad

More Related Content

More from CodeOps Technologies LLP (20)

Recently uploaded (20)

Advertisement

Build a Java Web Application using Azure Cosmos DB and the SQL API

  1. 1. Build a Java web application using Azure Cosmos DB and the SQL API
  2. 2. What will we create?
  3. 3. Prerequisites: • If you don't have an Azure subscription, create a free account before you begin. • Java Development Kit (JDK) 7+. • Eclipse IDE for Java EE Developers. • An Azure Web Site with a Java runtime environment (e.g. Tomcat or Jetty) enabled.
  4. 4. What will we learn? Create an Azure Cosmos DB account Create the Java JSP application Install the SQL Java SDK Use the Azure Cosmos DB service in our Java application Wire the rest of the of Java app together Deploy your Java application to Azure Web Sites
  5. 5. Create an Azure Cosmos DB account
  6. 6. Create the Java JSP application
  7. 7. Install the SQL Java SDK • The easiest way to pull in the SQL Java SDK and its dependencies is through Apache Maven. 1. Right-click your project in the Project Explorer, click Configure, click Convert to Maven Project. 2. In the Create new POM window, accept the defaults, and click Finish. 3. In Project Explorer, open the pom.xml file. 4. On the Dependencies tab, in the Dependencies pane, click Add. 5. In the Select Dependency window, do the following: • In the Group Id box, enter com.azure • In the Artifact Id box, enter azure-cosmos. • In the Version box, enter 4.0.1-beta.1
  8. 8. Use the Azure Cosmos DB service in our Java application • Add a model - First, we define a model within a new file TodoItem.java. • Add the Data Access Object(DAO) classes - Create the cosmosclientfactory class within the CosmosClientFactory.java file • Create a new TodoDao.java file and add the TodoDao class to create, update, read, and delete the todo items. • Create a new MockDao.java file and add the MockDao class this implements the ToDoDao class to perform CRUD operations on the items. • Create a DocdbDao.java file add Docdbdao class. This class defines code to persist the TodoItems into the container, retrieves our database and collection, if it exists, or create a new one if it doesn't exist. • Add a Controller • Create a Servlet
  9. 9. Wire the rest of the of Java app together • Now that we've finished the fun bits, all that's left is to build a quick user interface and wire it up to your DAO. 1.We need a web user interface to display to the user, and rewrite the index.js file. 2.Finally, write some client-side JavaScript to tie the web user interface and the servlet together.
  10. 10. Deploy Java application to Azure Web Sites 1. Now that you have a WAR file in hand, you can simply upload it to your Azure Web Site's webapps directory. 2. After the WAR file is uploaded to the webapps directory, the runtime environment will detect that you've added it and will automatically load it. 3. To view your finished product, navigate to http://YOUR_SITE_NAME.azurewebsites.net/azure-java- sample/ and start adding your tasks!
  11. 11. Deploy Java application to Azure Web Sites
  12. 12. Where to find this entire workshop? • Refer to: https://docs.microsoft.com/en- us/azure/cosmos-db/sql-api-java-application HaimantikaM Siliguri, India Haimantika Mitra

×