There are 2 ways to use this demo. You can deploy backing Azure services and run the Java microservices locally. This allows for local development and debugging.
Additionally, you can deploy everything to Azure and the microservices will be fully deployed to Azure Spring Apps or AKS.
Instructions for both are below.
In this step, you will provision the Azure resources needed to support Red Dog Java. This includes: Event-Hubs, Azure MySQL, Azure Redis, CosmosDB, Azure OpenAI Service, Azure Service Bus, Azure Key Vault, Storage Account, etc.
This script will also deploy ASA, AKS, ARO if needed.
-
Update/create the
config.json
file (in the./scripts
directory)-
The
deploytarget
setting determines if you will run local or use one of the Azure options -
Your file should look like this:
{ "location":"eastus", "username": "shortname", "adminpassword": "replaceSecurePassword", "_comment1": "for deploy target one of: local, asa, aks, aro", "deploytarget": "local" }
-
-
Run intial deployment script
cd scripts ./start.sh
-
Jump to the section below that matches your deployment
This deployment will require a bash shell of your choice. It will not work on Azure Cloud Shell.
-
Pre-requisites
- Java (JDK-17). https://learn.microsoft.com/en-us/java/openjdk/overview
JAVA_HOME
set to ^ JDK location
- Maven. https://maven.apache.org/download.cgi
- Bash
- Yarn
- Java (JDK-17). https://learn.microsoft.com/en-us/java/openjdk/overview
-
Setup local env variables
-
Script creates an output with the variables needed. Source the file in your
./outputs
directoryexport DEPLOY_UNIQUE_SUFFIX=12345 source ./outputs/var-reddog-spring-$DEPLOY_UNIQUE_SUFFIX.sh
-
-
Run microservices
-
Start with the order-service
cd order-service mvn clean package java -jar ./target/*.jar
-
Repeat for each of the other services:
- accounting-service
- makeline-service
- loyalty-service
- receipt-generation-service
- virtual-worker
- virtual-customer
-
-
Start the UI web app
-
Clone the repo (submodule in the existing repo): https://github.com/appdevgbb/reddog-ui-nextjs
-
Set the .env.local file
-
Start via yarn
yarn yarn dev
-
If you selected AKS as the deployment target, your terminal should have access to cluster and the apps were deployed via GitOps.
Review the pods deployed in the cluster and validate the application UI is functional.
Note: The manual steps for deploying the application in AKS are noted here: AKS Deployment Notes
Follow the steps below to deploy Red Dog to your Azure Spring Apps instance deployed in the previous step.
Note: These manual steps will be replaced with the Bicep script going forward.
-
Setup local env variables
-
From the root directory of the repo
-
Script creates an output with the variables needed. Source the file in your
./outputs
directoryexport DEPLOY_UNIQUE_SUFFIX=12345 source ./outputs/var-reddog-spring-$DEPLOY_UNIQUE_SUFFIX.sh
-
-
Deploy order-service:
# Set variables as needed export RG='' export SPRING_CLUSTER='' export SERVICE_NAME='order-service' az spring app create \ -n $SERVICE_NAME \ -s $SPRING_CLUSTER \ -g $RG \ --runtime-version Java_17 \ --assign-endpoint true \ --cpu 2 \ --memory 1Gi \ --instance-count 1 \ --env AZURECOSMOSDBURI=$AZURECOSMOSDBURI AZURECOSMOSDBKEY=$AZURECOSMOSDBKEY AZURECOSMOSDBDATABASENAME='reddog' KAFKASASLJAASCONFIG=$KAFKASASLJAASCONFIG KAFKABOOTSTRAPSERVERS=$KAFKABOOTSTRAPSERVERS KAFKASECURITYPROTOCOL='SASL_SSL' KAFKASASLMECHANISM='PLAIN' KAFKATOPICNAME='reddog' MYSQLURL=$MYSQLURL MYSQLUSER='reddog' MYSQLPASSWORD=$MYSQLPASSWORD AZUREREDISHOST=$AZUREREDISHOST AZUREREDISPORT='6380' AZUREREDISACCESSKEY=$AZUREREDISACCESSKEY AZURESTORAGEACCOUNTNAME=$AZURESTORAGEACCOUNTNAME AZURESTORAGEACCOUNTKEY=$AZURESTORAGEACCOUNTKEY AZURESTORAGEENDPOINT=$AZURESTORAGEENDPOINT KAFKATOPICGROUP=$SERVICE_NAME KAFKA_CONSUMER_GROUP_ID=$SERVICE_NAME KAFKA_COMPLETED_ORDERS_TOPIC='make-line-completed' az spring app deploy \ -s $SPRING_CLUSTER \ -g $RG \ --name $SERVICE_NAME \ --source-path ./$SERVICE_NAME # Check apps and logs az spring app list -s $SPRING_CLUSTER -g $RG az spring app logs -n $SERVICE_NAME -s $SPRING_CLUSTER -g $RG --lines 1000 az spring app logs -s $SPRING_CLUSTER -g $RG --lines 1000 -n order-service az spring app logs -n $SERVICE_NAME -s $SPRING_CLUSTER -g $RG -f # tail logs live # Delete if needed az spring app delete -n $SERVICE_NAME -s $SPRING_CLUSTER -g $RG
-
Deploy remaining microservices using the commands above. For each service, set the variable below and run the create/deploy commands.
export SERVICE_NAME='loyalty-service' export SERVICE_NAME='makeline-service' export SERVICE_NAME='accounting-service' export SERVICE_NAME='virtual-worker' export SERVICE_NAME='virtual-customers' # for virtual customers, add this ENV VAR ORDER_SVC_URL='' # for virtual worker, add this ENV VAR MAKELINE_SVC_URL=''
-
Deploy Dashboard UI (Custom Container) https://github.com/appdevgbb/reddog-ui-nextjs
export SERVICE_NAME='dashboard' # set variables to URL for each service before running command az spring app create \ -n $SERVICE_NAME \ -s $SPRING_CLUSTER \ -g $RG \ --assign-endpoint true \ --cpu 2 \ --memory 1Gi \ --instance-count 1 \ --env PORT='1025' VIRTUAL_CUSTOMERS_URL='' ORDERS_URL='' ACCOUNTING_URL='' OPENAI_URL='' WORKER_URL='' az spring app deploy \ -s $SPRING_CLUSTER \ -g $RG \ -n $SERVICE_NAME \ --container-image chzbrgr71/reddog-dashboard:v1
-
Deploy OpenAI Neural Network service
OpenAI Docs: https://learn.microsoft.com/en-us/azure/cognitive-services/create-account-bicep?tabs=CLI
export SERVICE_NAME='openai-svc' az spring app create \ -n $SERVICE_NAME \ -s $SPRING_CLUSTER \ -g $RG \ --assign-endpoint true \ --cpu 2 \ --memory 1Gi \ --instance-count 1 \ --env OPENAI_API_BASE='' OPENAI_API_KEY='' az spring app deploy \ -s $SPRING_CLUSTER \ -g $RG \ -n $SERVICE_NAME \ --container-image chzbrgr71/reddog-openai-svc:v1