Skip to content

Latest commit

 

History

History

04-configure-a-spring-cloud-config-server

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

04 - Configure a Spring Cloud Config server

This guide is part of the Azure Spring Cloud training

Configure a Spring Cloud Config Server, that will be entirely managed and supported by Azure Spring Cloud, to be used by Spring Boot microservices.


Create a Git repository for storing the application configuration

On your GitHub account, create a new private repository where the Spring Boot configurations will be stored.

⏱ If you want to skip the step of creating a private repository, you can use this public repository instead: https://github.com/jdubois/spring-cloud-config-public.git. Storing configuration in a public repository is not recommended in real-world deployments. We offer this public repository only as a shortcut for this workshop. If you choose to use this shortcut, skip to Configure Azure Spring Cloud to access the Git repository.

In the new private GitHub repository, add a new application.yml file which will store configuration data for all our microservices.

Typically, each Spring Boot application includes such a file with the application binaries to contain application settings. A Spring Cloud configuration server allow such settings to be stored at a single location and served from a single source.

For the moment, our application.yml will just store a message to check if the configuration is successful:

application:
    message: Configured by Azure Spring Cloud

Commit and push the new file.

Create a GitHub personal token

Azure Spring Cloud can access Git repositories that are public, secured by SSH, or secured using HTTP basic authentication. We will use that last option, as it is easier to create and manage with GitHub.

Follow the GitHub guide to create a personal token and save your token. When asked to select scopes, check off the entire "repo" section (as shown below) and nothing else.

GitHub personnal access token

When a token is generated, leave that tab open until the end of this section.

Configure Azure Spring Cloud to access the Git repository

  • Go to the Azure portal.
  • Go to the overview page of your Azure Spring Cloud server and select "Config server" in the menu
  • Configure the repository we previously created:
    • Add the repository URL, for example https://github.com/jdubois/azure-spring-cloud-config.git.

      💡 Make you include the .git ending in the URL.

    • Click on Authentication and select HTTP Basic

    • The username is your GitHub login name

    • The password is the personal token we created in the previous section

  • Click on "Apply" and wait for the operation to succeeed

Spring Cloud config server

Review

We have now created a private configuration repository. We have enabled Azure Spring Cloud to create a configuration server with the configuration files from this repository.

In the next section, we will create an application that consumes this configuration, specifically the custom message we defined in application.yml.


⬅️ Previous guide: 03 - Configure application logs

➡️ Next guide: 05 - Build a Spring Boot microservice using Spring Cloud features