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

Set up a configuration repository

Azure Spring Apps Enterprise service provides an Application Configuration Service for the use of Spring apps. As part of its setup, you need to link it to a git repo. The current configuration used by the Spring microservices resides in the config folder of the GitHub repository of 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.

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 Application Configuration Service. It is important that you make note of the PAT after it has been created.

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. In one of the exercises this config repository will contain a secret value.

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

  3. At the bottom of the vertical navigation menu, select Developer settings, select Personal access tokens, select Tokens (classic), and then select the Generate new token drop-down and option Generate new token (classic).

  4. 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.

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

  6. 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.

  7. 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. In case you haven’t already you can also clone here your code repository.

    cd ~/workspaces
    # Clone config repo
    git clone https://<token>@github.com/<your-github-username>/spring-petclinic-microservices-config.git
        
    # Clone source code repo
    git clone https://<token>@github.com/<your-github-username>/java-microservices-asa-e-lab.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.

  8. From the Git Bash prompt, change the current directory to the newly created spring-petclinic-microservices-config folder and run the following commands to copy all the config server configuration yaml files from the config folder of this labs’ GitHub repository to the local folder on your lab computer.

    cd spring-petclinic-microservices-config
    curl -o admin-server.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-asa-e-lab/master/config/admin-server.yml
    curl -o api-gateway.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-asa-e-lab/master/config/api-gateway.yml
    curl -o application.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-asa-e-lab/master/config/application.yml
    curl -o customers-service.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-asa-e-lab/master/config/customers-service.yml
    curl -o discovery-server.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-asa-e-lab/master/config/discovery-server.yml
    curl -o tracing-server.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-asa-e-lab/master/config/tracing-server.yml
    curl -o vets-service.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-asa-e-lab/master/config/vets-service.yml
    curl -o visits-service.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-asa-e-lab/master/config/visits-service.yml
    curl -o messaging-emulator.yml https://raw.githubusercontent.com/Azure-Samples/java-microservices-asa-e-lab/master/config/messaging-emulator.yml
    
  9. 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
    
  10. 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.