Create the java components for your config and discovery server
As a next step, you will configure some of the Spring Cloud components on your ACA environment, like the config server and the discovery server. These are available as build-in components on ACA. You can follow the below guidance to do so.
- Configure settings for the Config Server for Spring component in Azure Container Apps (preview)
- Tutorial: Connect to a managed Config Server for Spring in Azure Container Apps (preview)
- Configure settings for the Eureka Server for Spring component in Azure Container Apps (preview)
- Tutorial: Connect to a managed Eureka Server for Spring in Azure Container Apps (preview)
Step by step guidance
-
For configuring the config server, you will first create variables to support your application configuration. Fill out the right values for these variables. In case you want to use a different branch then the main branch, change the label variable to your branch name.
JAVA_CONFIG_COMP_NAME=myconfigserver URI="https://github.com/<your-github-username>/spring-petclinic-microservices-config.git" USERNAME=<your-github-username> PASSWORD="<the-GitHub-PAT-token-you-created>" LABEL=main
-
Now you can create the Spring Cloud Config Server Java component. You give it as a configuration your Git repo URI, password and the branch you are using.
az containerapp env java-component config-server-for-spring create \ --environment $ACA_ENVIRONMENT \ --resource-group $RESOURCE_GROUP \ --name $JAVA_CONFIG_COMP_NAME \ --configuration spring.cloud.config.server.git.uri=$URI spring.cloud.config.server.git.username=$USERNAME spring.cloud.config.server.git.password=$PASSWORD spring.cloud.config.server.git.default-label=$LABEL
-
You can now check the Spring Cloud Config Server Java component to see if it got created correctly.
az containerapp env java-component config-server-for-spring show \ --environment $ACA_ENVIRONMENT \ --resource-group $RESOURCE_GROUP \ --name $JAVA_CONFIG_COMP_NAME
-
As a next step you now create the Spring Cloud Eureka Java component. This will create a standard eureka or discovery endpoint within your ACA environment for your Java microservices to use.
JAVA_EUREKA_COMP_NAME=eureka az containerapp env java-component eureka-server-for-spring create \ --environment $ACA_ENVIRONMENT \ --resource-group $RESOURCE_GROUP \ --name $JAVA_EUREKA_COMP_NAME \ --configuration eureka.server.response-cache-update-interval-ms=10000
Azure Container Apps also has an internal naming mechanism for microservices to call into each other. The usage of the Eureka component is handy in case you are migrating an existing spring cloud application and you want to keep leveraging your current naming mechanism between microservices. In other cases you might use the internal naming mechanism ACA is already providing you.