Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Set up a configuration repository

The Spring Petclinic microservices provides a config server that your apps can use. You do need to however provide a git repository for this config server and link this git repo to the server. The current configuration used by the Spring microservices resides in the config folder of the GitHub repo for this lab. You will need to create your own private git repo in this exercise, since, in one of its steps, you will be changing some of the configuration settings.

We simplified some of the original config of the spring-petclinic-microservices application to make some of the lab steps easier to execute.

As part of the setup process, you need to create a Personal Access Token (PAT) in your GitHub repo and make it available to the config server. It is important that you make note of the PAT after it has been created.

Once you have your own config repository to work with, you will have to update the spring-petclinic-config-server/src/main/resources/application.yml file of the spring-petclinic-config-server application to make use of this new repo. At least, in case when you self host the config server. Luckily in ACA, we can make use of the build-in configserver component, which you will use in one of the next modules.

Step by step guidance

  1. On your lab computer, in your web browser, navigate to your GitHub account, navigate to the Repositories page and create a new private repository named spring-petclinic-microservices-config.

    Make sure to configure the repository as private.

  2. Once the repo gets created, copy the clone URL.

  3. To create a PAT, in your browser, select the avatar icon in the upper right corner, and then select Settings.

  4. At the bottom of the vertical navigation menu, select Developer settings, select Personal access tokens, and then select Generate new token.

  5. On the New personal access token page, in the Note text box, enter a descriptive name, such as spring-petclinic-config-server-token.

    There is a new Beta experience available on GitHub for more fine-grained access tokens. This experience will create a token with a more limited scope than full repository scope (which basically gives access to all your repositories). The lab will work as well with a more fine-grained token, in that case, in the Fine-grained tokens (Beta) token creation page, choose for Only select repositories and select your config repository. For the Repository permissions select for the Contents the Read-only access level. You can use this fine-grained token when you configure your config-server on Azure Spring Apps. We recommend you create a second token in case you also need a personal access token for interacting with the repositories from the Git Bash prompt.

  6. In the Select scopes section, select repo and then select Generate token.

  7. Record the generated token. You will need it in this and subsequent labs.

    You can check the validity of your token with the following statement: curl -XGET -H 'authorization: token <token_value>' 'https://api.github.com/repos/<user_name>/spring-petclinic-microservices-config'. This statement should succeed. If it does not, redo the above steps for generating the PAT token.

    In case you are running this lab in a GitHub codespace, you can use the same Create a codespace option as you did for the lab project for making edits in the config repo. In the config repository, go to Code and next Codespaces. Next select Create a codespace. Your codespace of the config repository will now get created in your browser window. You can do this instead of the below clone steps. You will need to execute the below curl steps in your codespace. In case you don’t see the Create a codespace option in your repository, add a README.md file, refresh the page and retry.

  8. From the Git Bash prompt, change the current directory to the workspaces folder. Next, clone the newly created GitHub repository by typing git clone , pasting the clone URL you copied into Clipboard in the previous step, and entering the PAT string followed by the @ symbol in front of github.com.

    cd ~/workspaces
    # Clone config repo
    git clone https://<token>@github.com/<your-github-username>/spring-petclinic-microservices-config.git
    

    Make sure to replace the <token> and <your-github-username> placeholders in the URL listed above with the value of the GitHub PAT and your GitHub user name when running the git clone command.

  9. From the Git Bash prompt, change the current directory to the newly created spring-petclinic-microservices-config folder and prepare all the config server configuration yaml files from the config folder of the GitHub repo for this lab to the local folder on your lab computer. Option 1, download via web url one by one:

    cd spring-petclinic-microservices-config
    curl -o application.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-aca-lab/main/config/application.yml
    curl -o api-gateway.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-aca-lab/main/config/api-gateway.yml
    curl -o customers-service.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-aca-lab/main/config/customers-service.yml
    curl -o discovery-server.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-aca-lab/main/config/discovery-server.yml
    curl -o tracing-server.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-aca-lab/main/config/tracing-server.yml
    curl -o vets-service.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-aca-lab/main/config/vets-service.yml
    curl -o visits-service.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-aca-lab/main/config/visits-service.yml
    curl -o chat-agent.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-aca-lab/main/config/chat-agent.yml
    

    Option 2, copy from the lab repo directory:

    cp ../java-microservices-aca-lab/config/*.yml .
    
  10. From the Git Bash prompt, run the following commands to commit and push your changes to your private GitHub repository.

    git add .
    git commit -m 'added base config'
    git push
    
  11. In your web browser, refresh the page of the newly created spring-petclinic-microservices-config repository and double check that all the configuration files are there.