forked from spring-cloud-services-samples/acme-fitness-store
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Azure Container Apps support (#213)
* add readme for aca * fix link * update remote uri * update comments * fix typo update variable/tag/logs add notes * add prefix * update pic * add resources for override * fix describe * fix name * add a note * add a note * delete sh * update * update * update * update * update * update tier to plan * update Azure Container Apps * fix link * Fix broken link * Update README.md * Update README.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update README.md * update * update * update * update * update * rollback ASA-E changes * rollback ASA-E changes * rollback ASA-E changes --------- Co-authored-by: Dingmeng Xue <[email protected]>
- Loading branch information
1 parent
3671fd3
commit f4e8a21
Showing
18 changed files
with
934 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Deploy Applications to Azure Container Apps | ||
|
||
This folder will help you deploy the Acme Fitness Store Application on Azure Container Apps step by step. | ||
|
||
## Table of Contents | ||
|
||
* [01-create-azure-containerapps-environment](./docs/01-create-azure-containerapps-environment.md) | ||
* [02-create-config-server](./docs/02-create-config-server.md) | ||
* [03-create-eureke-server](./docs/03-create-eureke-server.md) | ||
* [04-containerize-application](./docs/04-containerize-application.md) | ||
* [05-deploy-and-build-applications](./docs/05-deploy-and-build-applications.md) | ||
* [06-create-gateway-server](./docs/06-create-gateway-server.md) | ||
* [07-integrate-with-azure-database-for-postgresql-and-azure-cache-for-redis](./docs/07-integrate-with-azure-database-for-postgresql-and-azure-cache-for-redis.md) | ||
* [08-create-admin-server](./docs/08-create-admin-server.md) | ||
* [09-get-log-and-metrics](./docs/09-get-log-and-metrics.md) |
72 changes: 72 additions & 0 deletions
72
azure-container-apps/docs/01-create-azure-containerapps-environment.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Create Azure Container Apps Environment | ||
## Introduction | ||
This document provides a step-by-step guide to create an Azure Container Apps Environment. | ||
|
||
## Prerequisites | ||
- Install Azure CLI. For instructions, refer to [Azure CLI installation guide](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). | ||
- Azure subscription. | ||
- Install or update the Azure Container Apps extension for the Azure CLI: | ||
```bash | ||
az extension add --name containerapp --upgrade | ||
``` | ||
- Register the `Microsoft.App` and `Microsoft.OperationalInsights` namespaces: | ||
```bash | ||
az provider register --namespace Microsoft.App | ||
az provider register --namespace Microsoft.OperationalInsights | ||
``` | ||
|
||
## Outputs | ||
- Azure Container Apps Environment. | ||
|
||
## Steps | ||
|
||
### 1. Clone the repo | ||
Create a new folder and clone the sample app repository: | ||
```shell | ||
git clone https://github.com/Azure-Samples/acme-fitness-store.git | ||
cd acme-fitness-store | ||
``` | ||
|
||
### 2. Set Variables | ||
1. Create environment variables file setup-env-variables.sh based on template. | ||
```bash | ||
cp azure-container-apps/scripts/setup-env-variables-template.sh setup-env-variables.sh -i | ||
``` | ||
|
||
2. Update below resource information in `setup-env-variables.sh`: | ||
``` | ||
SUBSCRIPTION='subscription-id' # replace it with your subscription-id | ||
PREFIX='unique-prefix' # unique prefix for all resources(not use special characters) | ||
``` | ||
2. Set up the variables for your environment: | ||
```bash | ||
source setup-env-variables.sh | ||
az account set --subscription ${SUBSCRIPTION} | ||
echo "RESOURCE_GROUP=${RESOURCE_GROUP}" | ||
echo "ENVIRONMENT=${ENVIRONMENT}" | ||
echo "LOCATION=${LOCATION}" | ||
``` | ||
|
||
### 3. Create Resource Group | ||
Create a resource group to host all the Azure resources: | ||
```bash | ||
az group create \ | ||
--name ${RESOURCE_GROUP} \ | ||
--location ${LOCATION} | ||
``` | ||
|
||
### 4. Create Azure Container Apps Environment | ||
Create an Azure Container Apps Environment with system assigned managed identity: | ||
```bash | ||
az containerapp env create \ | ||
--name ${ENVIRONMENT} \ | ||
--resource-group ${RESOURCE_GROUP} \ | ||
--location ${LOCATION} \ | ||
--mi-system-assigned | ||
``` | ||
|
||
## Next Steps | ||
|
||
- Follow [02-create-config-server](./02-create-config-server.md) to create and deploy a Config Server on Azure Container Apps Environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Create Config Server for Spring | ||
## Introduction | ||
In this guide, you will learn how to create a Config Server for Spring component on Azure Container Apps Environment. The Config Server for Spring provides a centralized location to make configuration data available to multiple applications. For more information on using Config Server for Spring component, refer to the [official documentation](https://learn.microsoft.com/azure/container-apps/java-config-server-usage). | ||
|
||
## Prerequisites | ||
- Completion of [01-create-azure-containerapps-environment](./01-create-azure-containerapps-environment.md). | ||
|
||
## Outputs | ||
By the end of this guide, you will have a running Config Server for Spring component on your Azure Container Apps Environment. | ||
|
||
## Steps | ||
|
||
### 1. Verify Variables | ||
Verify the variables to create Config Server: | ||
```bash | ||
source setup-env-variables.sh | ||
|
||
echo "CONFIG_COMPONENT_NAME=${CONFIG_COMPONENT_NAME}" | ||
echo "CONFIG_SERVER_GIT_URI=${CONFIG_SERVER_GIT_URI}" | ||
``` | ||
|
||
### 2. Create Config Server for Spring Java component | ||
Create a Config Server on the existing Azure Container Apps Environment: | ||
```bash | ||
az containerapp env java-component config-server-for-spring create \ | ||
--environment ${ENVIRONMENT} \ | ||
--resource-group ${RESOURCE_GROUP} \ | ||
--name ${CONFIG_COMPONENT_NAME} \ | ||
--min-replicas 1 \ | ||
--max-replicas 1 \ | ||
--configuration spring.cloud.config.server.git.uri=${CONFIG_SERVER_GIT_URI} | ||
``` | ||
|
||
## Next Steps | ||
|
||
- Follow [03-create-eureke-server](./03-create-eureke-server.md) to create a eureka server on Azure Container Apps Environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Create Eureka Server for Spring | ||
## Introduction | ||
In this guide, you will learn how to create and deploy a Eureka Server for Spring component on Azure Container Apps Environment. Eureka Server for Spring is mechanism for centralized service discovery for microservices. See more details in [official documentation](https://learn.microsoft.com/azure/container-apps/java-eureka-server-usage). | ||
|
||
## Prerequisites | ||
- Completion of [02-create-config-server](./02-create-config-server.md). | ||
|
||
## Outputs | ||
By the end of this guide, you will have a running Eureka Server for Spring component on your Azure Container Apps Environment. | ||
|
||
## Steps | ||
|
||
### 1. Verify variables | ||
Verify the variables to create Eureka Server: | ||
```bash | ||
source setup-env-variables.sh | ||
|
||
echo "EUREKA_COMPONENT_NAME=${EUREKA_COMPONENT_NAME}" | ||
``` | ||
|
||
### 2. Create the Eureka Server for Spring Java component | ||
Create a Eureka Server on the existing Azure Container Apps Environment: | ||
```bash | ||
az containerapp env java-component eureka-server-for-spring create \ | ||
--environment ${ENVIRONMENT} \ | ||
--resource-group ${RESOURCE_GROUP} \ | ||
--name ${EUREKA_COMPONENT_NAME} | ||
``` | ||
|
||
## Next Steps | ||
|
||
- Follow [04-containerize-application](./04-containerize-application.md) to create a Admin Server on Azure Container Apps Environment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Containerize Applications using Buildpacks | ||
## Introduction | ||
This guide shows you how to create an Azure Container Registry (ACR), how to build the polyglot applications using Pack CLI on your local development machine and push them to Azure Container Registry (ACR). | ||
Buildpacks provide a higher-level abstraction for building container images. They take your application source code and transform it into a container image without the need for a Dockerfile. This process involves detecting the type of application, compiling the code, and packaging it with the necessary runtime dependencies. Buildpacks are particularly useful for polyglot environments where multiple languages and frameworks are used, as they can automatically handle the specifics of each technology stack. For more information, refer to the [official Buildpacks documentation](https://buildpacks.io/docs/). | ||
|
||
## Prerequisites | ||
- Completion of [03-create-eureke-server](./03-create-eureke-server.md). | ||
- Install Pack CLI. For instructions, refer to [Pack CLI installation guide](https://buildpacks.io/docs/for-platform-operators/how-to/integrate-ci/pack/). | ||
- Docker installed on your local machine. | ||
|
||
## Outputs | ||
- Azure Container Registry (ACR). This ACR will be used to store application images built by buildpack | ||
- Docker images for each application pushed to your ACR. | ||
|
||
## Steps | ||
|
||
### 1. Verify variables | ||
Verify the variables to create Azure Container Registry (ACR) and build the container images: | ||
```bash | ||
source setup-env-variables.sh | ||
|
||
echo "ACR_NAME=${ACR_NAME}" | ||
echo "ACR_LOGIN_SERVER=${ACR_LOGIN_SERVER}" | ||
echo "CATALOG_SERVICE_APP=${CATALOG_SERVICE_APP}" | ||
echo "PAYMENT_SERVICE_APP=${PAYMENT_SERVICE_APP}" | ||
echo "ORDER_SERVICE_APP=${ORDER_SERVICE_APPq}" | ||
echo "CART_SERVICE_APP=${CART_SERVICE_APP}" | ||
echo "FRONTEND_APP=${FRONTEND_APP}" | ||
echo "APP_IMAGE_TAG=${APP_IMAGE_TAG}" | ||
``` | ||
|
||
### 2. Prepare resources for Azure Container Apps used | ||
The source built previously for the Azure Spring Apps Enterprise plan does not include the Config Server dependency and configuration required by Azure Container Apps. Therefore, use the following commands to copy the necessary resources to the corresponding application. | ||
```bash | ||
cp azure-container-apps/resources/apps . -r | ||
``` | ||
|
||
### 3. Open your Docker environment | ||
Open your docker environment to build and push the images to ACR. | ||
|
||
### 4. Build applications | ||
The following commands will build each application using the Pack CLI and the Paketo Buildpacks builder. Each application will be built with the necessary runtime dependencies and tagged with the specified image tag. The built images will then be pushed to the Azure Container Registry. | ||
```bash | ||
# Build Catalog Service | ||
pack build ${ACR_LOGIN_SERVER}/${CATALOG_SERVICE_APP}:${APP_IMAGE_TAG} \ | ||
--path apps/acme-catalog \ | ||
--builder paketobuildpacks/builder-jammy-base \ | ||
-e BP_JVM_VERSION=17 | ||
|
||
# Build Payment Service | ||
pack build ${ACR_LOGIN_SERVER}/${PAYMENT_SERVICE_APP}:${APP_IMAGE_TAG} \ | ||
--path apps/acme-payment \ | ||
--builder paketobuildpacks/builder-jammy-base \ | ||
-e BP_JVM_VERSION=17 | ||
|
||
# Build Order Service | ||
pack build ${ACR_LOGIN_SERVER}/${ORDER_SERVICE_APP}:${APP_IMAGE_TAG} \ | ||
--path apps/acme-order \ | ||
--builder paketobuildpacks/builder-jammy-base | ||
|
||
# Build Cart Service | ||
pack build ${ACR_LOGIN_SERVER}/${CART_SERVICE_APP}:${APP_IMAGE_TAG} \ | ||
--path apps/acme-cart \ | ||
--builder paketobuildpacks/builder-jammy-base | ||
|
||
# Build Frontend App | ||
pack build ${ACR_LOGIN_SERVER}/${FRONTEND_APP}:${APP_IMAGE_TAG} \ | ||
--path apps/acme-shopping \ | ||
--builder paketobuildpacks/builder-jammy-base | ||
``` | ||
|
||
### 5. Create Azure Container Registry and Push Images | ||
1. Create Azure Container Registry (ACR) for storing application images built by buildpack: | ||
```bash | ||
az acr create \ | ||
-g ${RESOURCE_GROUP} \ | ||
-n ${ACR_NAME} \ | ||
--sku Premium | ||
``` | ||
|
||
2. Login the ACR | ||
```bash | ||
az acr login \ | ||
-n ${ACR_NAME} \ | ||
-g ${RESOURCE_GROUP} | ||
``` | ||
|
||
3. Push Docker images to container registry | ||
```bash | ||
docker push ${ACR_LOGIN_SERVER}/${CATALOG_SERVICE_APP}:${APP_IMAGE_TAG} | ||
docker push ${ACR_LOGIN_SERVER}/${PAYMENT_SERVICE_APP}:${APP_IMAGE_TAG} | ||
docker push ${ACR_LOGIN_SERVER}/${ORDER_SERVICE_APP}:${APP_IMAGE_TAG} | ||
docker push ${ACR_LOGIN_SERVER}/${CART_SERVICE_APP}:${APP_IMAGE_TAG} | ||
docker push ${ACR_LOGIN_SERVER}/${FRONTEND_APP}:${APP_IMAGE_TAG} | ||
``` | ||
|
||
## Next Steps | ||
|
||
- Follow [05-deploy-and-build-applications](./05-deploy-and-build-applications.md) to deploy and build the Acme applications. |
Oops, something went wrong.