Skip to content

Latest commit

 

History

History
 
 

custom-config-server-client

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Access Azure Spring Apps managed Config Server

This sample shows how to access Azure Spring Apps managed Config Server through Azure RBAC when your applications are running outside Azure Spring Apps.

Prerequisite

How to run

  1. Clone this repo and go to folder

    git clone https://github.com/Azure-Samples/Azure-Spring-Cloud-Samples
    cd Azure-Spring-Cloud-Samples/custom-config-server-client
  2. Install Azure CLI extension for Azure Spring Apps

    az extension add --name spring-cloud
  3. Create an instance of Azure Spring Apps

    az spring-cloud create -n <service name> -g <resource group name>
  4. Using piggymetrics-config as the backend git repo from which Azure Spring Apps to pull config

    az spring-cloud config-server git set --name <service name> --uri "https://github.com/Azure-Samples/piggymetrics-config.git"
  5. Create a service principal to access the Config Server in your application. Please mark down

    az ad sp create-for-rbac --scopes /subscriptions/<subscription id>/resourceGroups/<resource group name>/providers/Microsoft.AppPlatform/Spring/<service name> --role "Azure Spring Cloud Config Server Reader"

    The output includes credentials you will need in the next step.

  6. Update the application.properties under src/main/resources with the credentials you get above and your Azure Spring Apps instance.

    spring.cloud.config.uri=https://<service name>.svc.asc-test.net/config
    access.token.clientId=<appId>
    access.token.secret=<password>
    access.token.tenantId=<tenant>
  7. Package the app using maven and run it locally

    mvn clean package -D skipTests
    mvn spring-boot:run
  8. The endpoint should be access now with the configuration content

    curl http://127.0.0.1:8080/config
    20000%