This sample shows how to access Azure Spring Apps managed Config Server through Azure RBAC when your applications are running outside Azure Spring Apps.
-
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
-
Install Azure CLI extension for Azure Spring Apps
az extension add --name spring-cloud
-
Create an instance of Azure Spring Apps
az spring-cloud create -n <service name> -g <resource group name>
-
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"
-
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.
-
Update the
application.properties
undersrc/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>
-
Package the app using maven and run it locally
mvn clean package -D skipTests mvn spring-boot:run
-
The endpoint should be access now with the configuration content
curl http://127.0.0.1:8080/config 20000%