This guide provides step-by-step instructions to deploy the Angular front-end and the Spring Boot REST back-end of the Spring Petclinic application to Azure Container Apps.
- Azure CLI: Ensure you have the Azure CLI installed. You can download it from here.
- Docker: Ensure you have Docker installed. You can download it from here.
- Paketo
packbinary: Ensure you have the Paketopackbinary installed. You can download it from here.
-
Navigate to the Angular project directory:
cd spring-petclinic-angular -
Build the Docker image using Maven:
mvn clean install -Pdocker
Note: The
dockerMaven profile uses thepackbinary and thepaketobuildpacks/builder-jammy-basebuilder with thepaketo-buildpacks/nginxbuildpack to produce the Docker image.
The following options are passed to pack:
--buildpack paketo-buildpacks/nginx: Specifies the buildpack to use for building the image.--builder paketobuildpacks/builder-jammy-base: Specifies the builder image to use.--env PORT=8080: Sets the environment variablePORTto8080.--env BP_NODE_RUN_SCRIPTS=build: Sets the environment variableBP_NODE_RUN_SCRIPTStobuild.--env BP_WEB_SERVER=nginx: Sets the environment variableBP_WEB_SERVERtonginx.--env BP_WEB_SERVER_ENABLE_PUSH_STATE=true: Sets the environment variableBP_WEB_SERVER_ENABLE_PUSH_STATEtotrue.--env BP_NODE_VERSION=22.13.0: Sets the environment variableBP_NODE_VERSIONto22.13.0.--env BP_WEB_SERVER_ROOT=dist: Sets the environment variableBP_WEB_SERVER_ROOTtodist.
-
Navigate to the Spring Boot back-end project directory:
cd ../spring-petclinic-rest -
Build the Spring Boot application and Docker image using Maven:
mvn clean install -Pdocker
Note: The
dockerMaven profile uses thepackbinary and thepaketobuildpacks/builder-jammy-basebuilder and thetarget/${project.build.finalName}.jarJAR file to produce the Docker image.
The following options are passed to pack:
--builder paketobuildpacks/builder-jammy-base: Specifies the builder image to use.--buildpack paketo-buildpacks/microsoft-openjdk: Specifies the buildpack to use for the JDK.--buildpack paketo-buildpacks/java: Specifies the buildpack to use for Java applications.--env BP_JVM_VERSION=21: Sets the environment variableBP_JVM_VERSIONto21.--volume ${project.build.directory}/../src/main/paketo/bindings/application-insights:/platform/bindings/application-insights: Mounts the Application Insights bindings directory.
-
Log in to Azure:
az login
-
Create a resource group:
az group create --name myResourceGroup --location eastus
-
Create an Azure Container Registry (ACR):
az acr create --resource-group myResourceGroup --name myAcrRegistry --sku Basic
-
Log in to the ACR:
az acr login --name myAcrRegistry
-
Tag and push the Angular front-end Docker image:
docker tag spring-petclinic-angular:latest myacrregistry.azurecr.io/spring-petclinic-angular:latest docker push myacrregistry.azurecr.io/spring-petclinic-angular:latest
-
Tag and push the Spring Boot REST back-end Docker image:
docker tag spring-backend:latest myacrregistry.azurecr.io/spring-backend:latest docker push myacrregistry.azurecr.io/spring-backend:latest
-
Enable the Azure Container Apps extension:
az extension add --name containerapp --upgrade
-
Create an Azure Container Apps environment:
az containerapp env create --name myContainerAppEnv --resource-group myResourceGroup --location eastus
-
Deploy the Spring Boot back-end (private):
az containerapp create --name spring-backend --resource-group myResourceGroup --environment myContainerAppEnv --image myacrregistry.azurecr.io/spring-backend:latest --target-port 8080 --ingress 'internal' -
Deploy the Angular front-end:
az containerapp create --name angular-frontend --resource-group myResourceGroup --environment myContainerAppEnv --image myacrregistry.azurecr.io/angular-frontend:latest --target-port 80 --ingress 'external' --env-vars REST_API_URL=http://spring-backend:8080/petclinic/api/
-
Create an Application Insights resource:
az monitor app-insights component create --app myAppInsights --location eastus --resource-group myResourceGroup
-
Retrieve the connection string for the Application Insights resource:
az monitor app-insights component show --app myAppInsights --resource-group myResourceGroup --query connectionString --output tsv
-
Update the Azure Container Apps to use the Application Insights connection string:
az containerapp update --name spring-backend --resource-group myResourceGroup --environment myContainerAppEnv --env-vars APPLICATIONINSIGHTS_CONNECTION_STRING=<your_connection_string> az containerapp update --name angular-frontend --resource-group myResourceGroup --environment myContainerAppEnv --env-vars APPLICATIONINSIGHTS_CONNECTION_STRING=<your_connection_string>
You have successfully deployed the Angular front-end and the Spring Boot REST back-end to Azure Container Apps. The back-end is private and only accessible by the front-end.
To get the URL for the front-end, use the following Azure CLI command:
az containerapp show --name angular-frontend --resource-group myResourceGroup --query properties.configuration.ingress.fqdnFor your reference we are including some screenshots below that show:
-
Azure Portal - Front-end Deployment: This image shows the Angular front-end deployment details in the Azure portal.
-
Edge Browser - Front-end Application: This image shows the Angular front-end application running in the Edge browser.
-
Azure Portal - Back-end Deployment: This image shows the Spring Boot back-end deployment details in the Azure portal.
-
Swagger API Docs - Back-end: This image shows the Swagger API documentation for the Spring Boot back-end.
See Azure DevOps Pipeline example for a CI/CD pipeline example.
If you are looking to redeploy the two applications after your initial deployment, we recommend using the AzureContainerApps@1 task instead of the AzureCLI@2 task in the Deploy stage in the pipeline example.



