Skip to content

A sample order management solution for Azure + Java.

Notifications You must be signed in to change notification settings

tacowan/order-management-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Order Management for Java

This workshop walks through hosting an Azure-hosted solution utlizing Azure PaaS offerings and is geared toward Java developers.

Solution Overview

Your company has asked you to help build an order processing system in Azure. For the first portion of this project, you will rehost an existing Order Management App and Customer API that your company already uses. For the second portion of this project, you will build out an Azure Functions driven processing pipeline to complete the overall solution.

Solution Architecture

To accomplish this task, you will work through the following steps:

  1. Repository Setup
  2. Prepare you development environment
  3. Set up common Azure resources
  4. Deploy the Order Management App
  5. Deploy the Customer API and Database
  6. Deploy the Order API and Database
  7. [Deploy the Order Processing Pipeline]

Repository Setup

If the origin repository has not been forked into your personal GitHub account or your orgnaization's GitHub Organization, please do so before completing any additional steps.

Fork

Dev Environment Setup

To work effectively you'll need a fully functioning development environment. To keep from having to install a lot of dependencies, a GitHub codespace has been configured for your use. (These steps assume that the original repo has been forked into your GitHub organization.) Follow the steps below to set up your environment:

  1. In GitHub, create a new branch with your name or a custom identifier.
  2. Go to Code > New codespace to open up a development environment for your new branch.

Set Up common Azure Resources

For this project, you will have a number of Azure resources used for common concerns such as logging and file storage. In this section, we will set up those common resources so they can be used later in our project.

  1. Navigate to the Azure portal
  2. Create a new Resource Group to hold all of your Order Management Azure resources. NOTE: The Subscription, Resource Group, and Region used/created in this step should be used for all other resources being creating
    • Subscription: Your subscription
    • Name: order-management-[uniquename]-rg
  3. Create a new Log Analytics Workspace to hold all of your logs
    • Name: order-management-[uniquename]-log
  4. Create an Application Insights resource to capture application logs and metrics
    • Name: order-management-[uniquename]-ai
    • Resource Mode: Workspace-based
    • Log Analytics Workspace: order-management-[uniquename]-log
  5. Create a Storage Account to hold files and assets
    • Name: ordermanagement[uniquename]st
    • Redundancy: Locally-redundant storage (LRS)

Deploy the Order Management App

The Order Management App is a Single Page Application (Angular) that has been transpiled into static assets for hosting. For our purposes, we will host the App as a Static Website from our Storage Account for web access.

  1. Turn on Static Website hosting for your Storage Account
    1. In the Azure Portal, navigate to your Storage Account
    2. In the side menu select Data management > Static website
    3. Toggle the Static website to Enabled
    4. Set the site information
      • Index document name: index.html
      • Error document path: index.html
  2. Deploy the application to your Storage Account
    1. In your Codespace, right click on order-management-app and select Deploy to Static Website via Azure Storage...
    2. Select your storage account
  3. Add the Application Insights information to the App
    1. Navigate to the App (https://[storageaccountname].z13.web.core.windows.net)
    2. Select the settings Cog in the top right corner of the app
    3. Add the Application Insights connection string to the settings

Deploy the Customer API and Database

The Customer API is a Spring API that interacts with Customer database to track customer information. We will host the API in Azure App Service and the database in Azure SQL Database.

  1. Provision and deploy the Customer database

    1. In the Azure Portal, create an Azure SQL Database
      • Database name: customer-sqldb
      • Server: Create New
        • Server Name: customer-/[uniquename/]-sqlsvr
        • Server admin login: customeradmin
        • Password: ABCD1234abcd!
        • Confirm password: ABCD1234abcd!
      • Compute + storage: Configure Database
        • Service tier: Basic
      • Backup storage redundancy: Locally-redundant backup storage
    2. Update the Customer database schema
      1. In the Azure Portal, navigate to the Customer database

      2. In the side menu, select Query editor

      3. Try to log in with your credentials:

        • Login: customeradmin
        • Password: ABCD1234abcd!
      4. If you receive a networking access error, click the link at the end to add your IP address to the whitelist rules.

      5. In the query editor, run the following SQL:

        CREATE TABLE Customers (
            Id UNIQUEIDENTIFIER NOT NULL,
            Name NVARCHAR(100) NOT NULL,
            CONSTRAINT PK_Customers_Id PRIMARY KEY CLUSTERED (Id)
        );
  2. Provision and deploy the Customer API

    1. In the Azure Portal, create an Azure App Service Web App
      • Name: customer-api-[uniquename]-app
      • Runtime stack: Java 11
      • Linux Plan: Create New
        • Name: customer-api-plan
      • Sku and size: Dev/Test B1
    2. Update the Web App settings with the database information
      1. Navigate to the App Service Web App
      2. In the side menu, select Settings > Configuration and add the following Application Settings
        • DB_SERVER_NAME: customer-[uniquename]-sqlsvr
        • DB_NAME: customer-sqldb
        • DB_USERNAME: customeradmin
        • DB_PASSWORD: ABCD1234abcd!
    3. Deploy the Customer API to the Azure App Service Web App
      1. In your Codespace, open up a new Terminal Terminal > New Terminal

      2. In the terminal build the API with Maven

        cd customer-api
        mvnw package
      3. In the file explorer, right click on customer-api > target > customer-api-0.0.1-SNAPSHOT.jar and select Deploy to Web App

      4. Select your Subscription and Web App

    4. Troubleshoot your Customer API
      1. Navigate to your Customer API in your browser (https://customer-api-[uniquename]-app.azurewebsites.net)
      2. In the Azure Portal, navigate to your App Service Monitoring > Log stream to identify the issue
      3. In the Azure SQL Server resource, navigate to Security > Firewalls and virtual networks
        • Allow Azure services and resources to access this server: Yes
      4. Navigate to your Customer API again
  3. Access the Customer API through the Order Management App

    1. Navigate to the Order Management App (https://[storageaccountname].z13.web.core.windows.net)
    2. In the settings, add in the base URL for the Customer API (https://customer-api-[uniquename]-app.azurewebsites.net)
    3. The navigate to the Customer section after it appears
    4. Troubleshoot calls to the Customer APi
      1. Open up the developer tools in your browser (F12) to troubleshoot the problem
        1. Note the CORS error
      2. Navigate to the Customer API in the Azure Portal
      3. In the side menu, select API > CORS and add * to the list of Allowed Origins
        1. Note, it will take a few minutes for this update to occur once you save
      4. Refresh the Order Management App to show the list of customers

Deploy the Order API and Database

About

A sample order management solution for Azure + Java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published