Giter VIP home page Giter VIP logo

azure-samples / acme-fitness-store Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spring-cloud-services-samples/acme-fitness-store

83.0 10.0 156.0 121.75 MB

Sample - how to deploy Spring Boot apps to Azure?

Home Page: https://docs.microsoft.com/en-us/azure/spring-cloud/overview

License: MIT License

Python 2.05% Shell 5.40% Dockerfile 0.06% Procfile 0.01% HTML 24.06% Java 8.54% C# 2.59% JavaScript 1.22% CSS 53.60% HCL 1.53% Starlark 0.23% Smalltalk 0.71%
automation azureactivedirectory eureka github-actions java keyvault-secrets kubernetes monitoring postgresql springboot springcloud springcloudconfig springcloudgateway sso-authentication gradle

acme-fitness-store's Introduction

page_type languages products description urlFragment
sample
java
Azure Spring Apps
Azure Database for PostgreSQL
Azure Cache for Redis
Azure Active Directory
Deploy Microservice Apps to Azure
acme-fitness-store

ACME Fitness Store

Check Markdown Links

ACME Fitness store is a fictional online retailer selling sporting goods. This repo contains the source code and deployment scripts for the ACME Fitness store application.

High Level Architecture

An image showing the services involved in the ACME Fitness Store. It depicts the applications and their dependencies

This application is composed of several services:

  • 4 Java Spring Boot applications:

    • A catalog service for fetching available products.
    • A payment service for processing and approving payments for users' orders
    • An identity service for referencing the authenticated user
    • An assist service for infusing AI into fitness store
  • 1 Python application:

    • A cart service for managing a users' items that have been selected for purchase
  • 1 ASP.NET Core applications:

    • An order service for placing orders to buy products that are in the users' carts
  • 1 NodeJS and static HTML Application

    • A frontend shopping application

The sample can be deployed to Azure Spring Apps Enterprise or Tanzu Application Platform.

Repo Organization

Directory Purpose
apps/ source code for the services
azure-spring-apps-enterprise/ documentation and scripts for deploying to Azure Spring Apps Enterprise
tanzu-application-platform/ documentation and scripts for deploying to Tanzu Application Platform

Deploy Apps to Azure Spring Apps Enterprise (ASA-E)

Azure Spring Apps Enterprise enables you to easily run Spring Boot and polyglot applications on Azure. The quickstart guide in azure-spring-apps-enterprise/README.md shows you how to deploy the ACME Fitness store application to Azure Spring Apps Enterprise.

Deploy Apps to Tanzu Application Platform (TAP)

Tanzu Application Platform (TAP) enables you to easily build & run polyglot applications on CNCF Compliant Kubernetes clusters. Follow the instructions in tanzu-application-platform/README.md to deploy the application to TAP.

Notes

If you would like to conduct this workshop in Japanese, please use the Japanese version.

日本語で、本ワークショップを実施されたい方は、、日本語版をご利用ください。Thanks for the contribution from @yoshioterada.

acme-fitness-store's People

Contributors

anishp55 avatar asaikali avatar bshetti avatar candicenonsense avatar dingmeng-xue avatar eddumelendez avatar ericm48 avatar felipmiguel avatar guitarsheng avatar ishrivatsa avatar kelwinpa avatar kvmw avatar lgdoor avatar littlebaibai avatar maly7 avatar manojsingh avatar markpollack avatar moarychan avatar murthy-vmware avatar mylesagray avatar nevenc avatar nickdala avatar odedia avatar retgits avatar roberto-mardeni avatar saragluna avatar selvasingh avatar sneezry avatar yoshioterada avatar yuwzho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acme-fitness-store's Issues

ERROR: usage error: --resource ID | --resource NAME --resource-group NAME --resource-type TYPE [--resource-parent PARENT] [--resource-namespace NAMESPACE]

I encounter the following error message

ERROR: usage error: --resource ID | --resource NAME --resource-group NAME --resource-type TYPE [--resource-parent PARENT] [--resource-namespace NAMESPACE]

when exe the command:

 az monitor diagnostic-settings create --name "send-logs-and-metrics-to-log-analytics" \
    --resource-id ${SPRING_CLOUD_RESOURCE_ID} \
    --workspace ${LOG_ANALYTICS_RESOURCE_ID} \
    --logs '[
         {
           "category": "ApplicationConsole",
           "enabled": true,
           "retentionPolicy": {
             "enabled": false,
             "days": 0
           }
         },
         {
            "category": "SystemLogs",
            "enabled": true,
            "retentionPolicy": {
              "enabled": false,
              "days": 0
            }
          },
         {
            "category": "IngressLogs",
            "enabled": true,
            "retentionPolicy": {
              "enabled": false,
              "days": 0
             }
           }
       ]' \
       --metrics '[
         {
           "category": "AllMetrics",
           "enabled": true,
           "retentionPolicy": {
             "enabled": false,
             "days": 0
           }
         }
       ]'

My env: windows 11, git-bash

01-workshop-setup for AI and 02-prepare-azure-openai

instructions ask to edit a file and set AZURE_OPENAI_APIKEY in a script, then in part 2 asked to export OPENAI_RESOURCE_NAME in a small shell script. we should set the OPENAI_RESOURCE_NAME in the script, and export the AZURE_OPENAI_APIKEY later

Catalog, Payment and Identity services fail to start

Following the steps of the tutorial deploying an Azure Spring Apps service in East US results in failed application deployment for the Catalog, Payment and Identity services.

See below logs for the partial Payment service deployment logs:

`Paketo Syft Buildpack 1.10.0
https://github.com/paketo-buildpacks/syft
Reusing cached download from buildpack
Writing env.build/SYFT_CHECK_FOR_APP_UPDATE.default

Paketo Gradle Buildpack 6.4.2
https://github.com/paketo-buildpacks/gradle
Build Configuration:
$BP_GRADLE_BUILD_ARGUMENTS --no-daemon assemble the arguments to pass to Gradle
$BP_GRADLE_BUILD_FILE the location of the main build config file, relative to the application root
$BP_GRADLE_BUILT_ARTIFACT build/libs/*.[jw]ar the built application artifact explicitly. Supersedes $BP_GRADLE_BUILT_MODULE
$BP_GRADLE_BUILT_MODULE the module to find application artifact in
Creating cache directory /home/cnb/.gradle
Compiled Application: Contributing to layer
Executing gradlew --no-daemon assemble
Downloading https://services.gradle.org/distributions/gradle-7.4.1-bin.zip
...........10%...........20%...........30%...........40%...........50%...........60%...........70%...........80%...........90%...........100%

Welcome to Gradle 7.4.1!

Here are the highlights of this release:

  • Aggregated test and JaCoCo reports
  • Marking additional test source directories as tests in IntelliJ
  • Support for Adoptium JDKs in Java toolchains

For more details see https://docs.gradle.org/7.4.1/release-notes.html

To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.4.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build

Task :compileJava
Task :processResources
Task :classes
Task :bootJarMainClassName
Task :bootJar
Task :jar
Task :assemble

BUILD SUCCESSFUL in 1m 1s
5 actionable tasks: 5 executed

Removing source code
Restoring multiple artifacts

Paketo Executable JAR Buildpack 6.2.0
https://github.com/paketo-buildpacks/executable-jar
Process types:
executable-jar: java -jar /workspace/acme-payment-0.0.1-SNAPSHOT.jar (direct)
task: java -jar /workspace/acme-payment-0.0.1-SNAPSHOT.jar (direct)
web: java -jar /workspace/acme-payment-0.0.1-SNAPSHOT.jar (direct)

Paketo Azure Application Insights Buildpack 5.4.2
https://github.com/paketo-buildpacks/azure-application-insights
Azure Application Insights Java Agent 3.2.11: Contributing to layer
Reusing cached download from buildpack
Copying to /layers/paketo-buildpacks_azure-application-insights/azure-application-insights-java
Writing env.launch/JAVA_TOOL_OPTIONS.append
Writing env.launch/JAVA_TOOL_OPTIONS.delim
Launch Helper: Contributing to layer
Creating /layers/paketo-buildpacks_azure-application-insights/helper/exec.d/properties
Adding layer 'paketo-buildpacks/ca-certificates:helper'
Adding layer 'paketo-buildpacks/microsoft-openjdk:helper'
Adding layer 'paketo-buildpacks/microsoft-openjdk:java-security-properties'
Adding layer 'paketo-buildpacks/microsoft-openjdk:jdk'
Adding layer 'paketo-buildpacks/azure-application-insights:azure-application-insights-java'
Adding layer 'paketo-buildpacks/azure-application-insights:helper'
Adding layer 'launch.sbom'
Adding 1/1 app layer(s)
Adding layer 'launcher'
Adding layer 'config'
Adding layer 'process-types'
Adding label 'io.buildpacks.lifecycle.metadata'
Adding label 'io.buildpacks.build.metadata'
Adding label 'io.buildpacks.project.metadata'
Setting default process type 'web'
Saving acr4b04ad7888ce4ea5b.azurecr.io/build-service-result-image-cab1d346fdbd45a391af896367d177be-default-payment-service:result-1...
*** Images (sha256:96a12590c49bcbe93f4a357e895c71c26985e2b44821cec37cd44a08aafa59cb):
acr4b04ad7888ce4ea5b.azurecr.io/build-service-result-image-cab1d346fdbd45a391af896367d177be-default-payment-service:result-1
Adding cache layer 'paketo-buildpacks/microsoft-openjdk:jdk'
Adding cache layer 'paketo-buildpacks/syft:syft'
Adding cache layer 'paketo-buildpacks/gradle:application'
Adding cache layer 'paketo-buildpacks/gradle:cache'
Adding cache layer 'cache.sbom'
[5/5] Updating deployment in app "payment-service" (this operation can take a while to complete)
112404: Failed to wait for deployment instances to be ready. Please check the application log (see https://aka.ms/azure-spring-cloud-doc-log ), and try again later.`

When checking the application logs with az spring app logs -n $PAYMENT_SERVICE_APP the following is available:

2022-06-01 14:35:15.541 INFO 1 --- [ main] c.v.acme.payment.PaymentApplication : Starting PaymentApplication using Java 11.0.14 on payment-service-default-15-d64965f75-xp84s with PID 1 (/workspace/acme-payment-0.0.1-SNAPSHOT.jar started by cnb in /workspace) 2022-06-01 14:35:17.031 INFO 1 --- [ main] c.v.acme.payment.PaymentApplication : No active profile set, falling back to 1 default profile: "default" 2022-06-01 14:35:23.054 INFO 1 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=fa1fe375-0a10-380c-9ee8-2ea19f46f0cf 2022-06-01 14:35:23.245 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2022-06-01 14:35:23.247 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig' of type [org.springframework.cloud.client.loadbalancer.reactive.LoadBalancerBeanPostProcessorAutoConfiguration$ReactorDeferringLoadBalancerFilterConfig] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2022-06-01 14:35:23.248 INFO 1 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'reactorDeferringLoadBalancerExchangeFilterFunction' of type [org.springframework.cloud.client.loadbalancer.reactive.DeferringLoadBalancerExchangeFilterFunction] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) Terminating due to java.lang.OutOfMemoryError: Metaspace

When the JVM option is added with -XX:MaxMetaspaceSize=148644K to override the default calculated value of 74322K the issue is resolved and the application is able to start successfully.

deploy.sh script should not change default az cli settings

Currently the ./deploy.sh script makes a call to the function

function configure_defaults() {
  echo "Configure azure defaults resource group: $RESOURCE_GROUP and spring $SPRING_APPS_SERVICE"
  az configure --defaults group=$RESOURCE_GROUP spring=$SPRING_APPS_SERVICE location=${REGION}
}

It is surprising that the script changes the defaults settings for the az cli, it is better if the script uses the passed in args -r, -s, -g without changing defaults

function configure_defaults() {

Content is not compliant with real testing

In the following paragraph of the start:

Note - The Bash shell. While Azure CLI should behave identically on all environments, shell semantics vary. Therefore, only bash can be used with the commands in this repo. To complete these repo steps on Windows, use Git Bash that accompanies the Windows distribution of Git. Use only Git Bash to complete this training on Windows. Do not use WSL.

git bash may not work for all the places, for example:
In this section:

Create a Service Principal
    az ad sp create-for-rbac --role contributor --scopes /subscriptions/${SUBSCRIPTION} --sdk-auth

throws:

ERROR: Error occurred in request., InvalidSchema: No connection adapters were found for 'C:/Program Files/Git/subscriptions/subscription-id-xxxx/providers/Microsoft.Authorization/roleDefinitions?$filter=roleName%20eq%20%27contributor%27&api-version=2018-01-01-preview'

And if I use cmd, it works! git bash is only for those command for env variables setting operation.

README.md az spring create, gives error

Command:
az spring create --name ${SPRING_APPS_SERVICE}
--resource-group ${RESOURCE_GROUP}
--location ${REGION}
--sku Enterprise
--enable-application-configuration-service
--enable-service-registry
--enable-gateway
--enable-api-portal
--enable-alv
--enable-app-acc
--build-pool-size S2

This command gives error as
unrecognized arguments: --enable-alv --enable-app-acc

I even tried with --enable-application-live-view --enable-application-accelerator. But got the same error

Review Spring app for modernization

Hey @egamma we need to modernize this Spring App and bring it to the cloud for better scale.

Given your extensive Java and JUnit skills 😎 can you please help us on this effort. Please take a look at the tasks below:

  • Review the tests
  • Clean-up the TO DOs
  • Check the security setup

Allow users to specify the Redis and Postgres server name

When trying to provision the Redis server and Postgres server, it will complain:

(NameNotAvailable) An error occured when trying to reserve the DNS name for the cache instance. This may be a temporary issue if a cache instance of this name was recently deleted. Please choose a different name or try again later.
RequestID=a49e924d-b6c0-43e3-ab99-8c7b41ac9ea8

and

az postgres flexible-server create --name ${POSTGRES_SERVER} \
    --resource-group ${RESOURCE_GROUP} \
    --location ${REGION} \
    --admin-user ${POSTGRES_SERVER_USER} \
    --admin-password ${POSTGRES_SERVER_PASSWORD} \
    --yes
Checking the existence of the resource group 'xxx'...
Resource group 'xxx' exists ? : True
Specified server name is already used.

Maybe we should let users configure the AZURE_CACHE_NAME and POSTGRES_SERVER like other Azure Resources.

add resoure-group option for the commands

We should add the resource-group option like the others.

az postgres flexible-server db create \
  --resource-group ${RESOURCE_GROUP} \
  --database-name ${ORDER_SERVICE_DB} \
  --server-name ${POSTGRES_SERVER}

az postgres flexible-server db create \
  --resource-group ${RESOURCE_GROUP} \
  --database-name ${CATALOG_SERVICE_DB} \
  --server-name ${POSTGRES_SERVER}

Create routing rules instructions are incorrect in 5

image

routes-file paths are incorrect

must be

az spring gateway route-config create
--name ${CART_SERVICE_APP}
--app-name ${CART_SERVICE_APP}
--routes-file ./azure-spring-apps-enterprise/resources/json/routes/cart-service.json

az spring gateway route-config create
--name ${ORDER_SERVICE_APP}
--app-name ${ORDER_SERVICE_APP}
--routes-file ./azure-spring-apps-enterprise/resources/json/routes/order-service.json

az spring gateway route-config create
--name ${CATALOG_SERVICE_APP}
--app-name ${CATALOG_SERVICE_APP}
--routes-file ./azure-spring-apps-enterprise/resources/json/routes/catalog-service.json

Issue in Unit-1 while creating an instance of Azure Spring Apps Enterprise

In Unit 1 - Deploy and Build Applications, facing an issue while creating an instance of Azure Spring Apps Enterprise.

After running the given below command, it will create a Azure Spring Apps resource but that is in Failed status:

az spring create --name ${SPRING_APPS_SERVICE} \
    --resource-group ${RESOURCE_GROUP} \
    --location ${REGION} \
    --sku Enterprise \
    --enable-application-configuration-service \
    --enable-service-registry \
    --enable-gateway \
    --enable-api-portal \
    --build-pool-size S2 

Please find the below screenshots FYR:

image

image

In Unit 3, service connector create failed and catalog-service restart failed

  • create Service Connector for catalog service failed

image

This is a problem in Service Connector and will be fix in Jan.

We could follow this doc to set it manually with Azure hosting service.

  • catalog-service restart failed

Now should add a new environment variable: spring.datasource.azure.passwordless-enabled=true.

az spring app update --name ${CATALOG_SERVICE_APP} --env "spring.datasource.azure.passwordless-enabled=true"

Service Connector will add this configuration in the future, but now it should be added manually.

incorrect setup instructions

image

The file path is different ./scripts no longer work
Looks like the create command for setup-env-variables.sh is missing

azure/deploy.sh missing -r option in usage

the azure/deploy.sh script usage output indicates you need to pass in -s and -g options however, to run you need to also provide -r option indicating the region.

Add usage description for -r to the azure/deploy.sh script

command to retrieve ids fails in codespaces. 01-workshop-environment-setup

fails

export LOG_ANALYTICS_RESOURCE_ID=$(az monitor log-analytics workspace show \ 
    --resource-group ${RESOURCE_GROUP} \ 
    --workspace-name ${LOG_ANALYTICS_WORKSPACE} | jq -r '.id')  

works
export LOG_ANALYTICS_RESOURCE_ID=$(az monitor log-analytics workspace show --resource-group ${RESOURCE_GROUP}  --workspace-name ${LOG_ANALYTICS_WORKSPACE} | jq -r '.id')

Change default branch from Azure to main

We are in the process of syncing this repo with the upstream repo it is forked from. The code in the Azure branch of this repo is reflected in the upstream main branch. However the github actions in this repo are all triggered on the Azure branch. Given the branch name difference between upstream and this repo we should change the branch name in this repo to be main to match upstream.

Azure CLI spring-cloud command is deprecated

When running all az spring-cloud xxx commands, it prints something like the following:

This command is implicitly deprecated because command group 'spring-cloud gateway route-config' is deprecated and will be removed in a future release. Use 'spring gateway route-config' instead.

Maybe we should switch to az spring instead.

deploy.sh fails because it does not generate globally unique names for azure services

Some azure services require globally unique names across all of azure according to azure docs Naming rules and restrictions for Azure resources the Redis and postgres services must have globally unique names.

The ./azure/deploy.sh fails when it tries to create the redis cache because the name is not globally unique.

./deploy.sh -g demo -r germanywestcentral -s demo-asa-instance
Configure azure defaults resource group: demo and spring demo-asa-instance
Creating Azure Cache for Redis Instance fitness-cache in location eastus
(NameNotAvailable) An error occured when trying to reserve the DNS name for the cache instance. This may be a temporary issue if a cache instance of this name was recently deleted. Please choose a different name or try again later.
RequestID=ec628194-f0cb-47b5-b745-e26da796ee9d
Code: NameNotAvailable
Message: An error occured when trying to reserve the DNS name for the cache instance. This may be a temporary issue if a cache instance of this name was recently deleted. Please choose a different name or try again later.
RequestID=ec628194-f0cb-47b5-b745-e26da796ee9d

It seems that the azure redis service requires a unique dns name for each instance of redis under the .redis.cache.windows.net domain. The script should be modified to generate a unique name for the redis service.

Also the postgres service creation will fail with the same issue.

AI workshop setup instructions are incorrect

it says cp azure-spring-apps-enterprise/scripts/setup-ai-env-variables-template.sh azure-spring-apps-enterprise/scripts/setup-ai-env-variables.sh

in the fitness repo intermediate workshop, it appears to be creating everything in the project root directory. BTW, many of the values that need to be set in the bash file are not yet available hence, the follow on fails as well.

source ./azure-spring-apps-enterprise/scripts/setup-ai-env-variables.sh

PostgreSQL Passwordless Support

Unit 3 use Connector Service for PostgreSQL passwordless connections.

Unit 4 drop PostgreSQL passwordless connections after use KeyVault as secret management.

Unit 7 don't use PostgreSQL passwordless connections in terraform.

I think all of them should use passwordless connections, it's more security for customers.

Review Spring Service Backend Tests

Hey @egamma we need to modernise this Spring App and bring it to the cloud for better scale.

Given your extensive Java and JUnit skills 😎 can you please help us on this effort. Please take a look at the tasks below:

  • Review the tests
  • Clean-up the TO DOs
  • Check the security setup

[Question] Why the client-type for the Python Cart Service is Java

When trying to create the Service Connector for the Cart Service to Azure Cache for Redis, seems like the cart service is a Python application, why the client type is set to Java?

az spring-cloud connection create redis \
    --resource-group ${RESOURCE_GROUP} \
    --service ${SPRING_CLOUD_SERVICE} \
    --connection $CART_SERVICE_CACHE_CONNECTION \
    --app ${CART_SERVICE_APP} \
    --deployment default \
    --tg ${RESOURCE_GROUP} \
    --server ${AZURE_CACHE_NAME} \
    --database 0 \
    --client-type java 

Update provision pipeline to use Terraform only - ensures declarative and can be reconciled against desired state

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.