Skip to content

codiebyheaart/spring-boot-azure-app-configuration

Repository files navigation

Spring Boot Azure App Configuration Integration

Seamlessly integrate Azure App Configuration with Spring Boot for dynamic configuration management - A production-ready Maven project demonstrating cloud-native configuration patterns with Azure services.

Spring Boot Azure Java Maven

Table of Contents

Overview

This Spring Boot application demonstrates enterprise-grade integration with Azure App Configuration, enabling centralized configuration management, dynamic updates, and feature flag control without application restarts. Perfect for microservices architectures and cloud-native applications.

Key Benefits

Centralized Configuration - Manage all application settings from Azure
Dynamic Updates - Refresh configurations without redeployment
Feature Flags - Control feature rollouts dynamically
Secure Secrets - Integration with Azure Key Vault
Environment Isolation - Separate configs for dev, staging, production

Features

  • Spring Boot 2.7.15 with Maven build system
  • Azure App Configuration integration via Spring Cloud Azure
  • Bootstrap configuration for early-stage property loading
  • RESTful API endpoints for configuration testing
  • Managed Identity support for Azure authentication
  • Development-ready with debug endpoints
  • Production-ready packaging and deployment

Prerequisites

Before running this application, ensure you have:

Verify Installation

java -version    # Should show Java 11 or higher
mvn -version     # Should show Maven 3.6 or higher

Quick Start

1. Clone the Repository

git clone https://github.com/yourusername/spring-boot-azure-app-configuration.git
cd spring-boot-azure-app-configuration

2. Configure Azure Connection

Edit src/main/resources/bootstrap.yml and add your Azure App Configuration connection string:

spring:
  cloud:
    azure:
      appconfiguration:
        stores:
          - connection-string: "Endpoint=https://your-config-store.azconfig.io;Id=XXXX;Secret=XXXX"

3. Build the Project

mvn clean install

4. Run the Application

mvn spring-boot:run

The application will start on http://localhost:8080

Project Structure

spring-boot-azure-app-configuration/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ main/
β”‚   β”‚   β”œβ”€β”€ java/com/example/nftclubcoinapp/
β”‚   β”‚   β”‚   β”œβ”€β”€ NftClubcoinAppApplication.java    # Main application class
β”‚   β”‚   β”‚   β”œβ”€β”€ controller/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ ConfigController.java         # Configuration endpoints
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AuthController.java           # Authentication endpoints
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ UserController.java           # User management
β”‚   β”‚   β”‚   β”‚   └── ...                           # Other controllers
β”‚   β”‚   β”‚   └── util/
β”‚   β”‚   β”‚       └── StaticResponseUtil.java       # Utility classes
β”‚   β”‚   └── resources/
β”‚   β”‚       └── bootstrap.yml                     # Azure configuration
β”‚   └── test/                                     # Test files
β”œβ”€β”€ target/                                       # Maven build output
β”œβ”€β”€ pom.xml                                       # Maven dependencies
β”œβ”€β”€ MAVEN_README.md                               # Technical documentation
└── README.md                                     # This file

API Endpoints

Once running, the following endpoints are available:

Endpoint Method Description Example Response
/config GET Get single configuration value "Value from Azure App Configuration: myValue"
/config/json GET Get all configurations as JSON {"name1": "value1", "name2": "value2"}
/env GET Get environment property "Environment property 'name1': value1"
/debug GET Debug Azure App Configuration Detailed configuration sources

Example Request

# Test the JSON configuration endpoint
curl http://localhost:8080/config/json

Expected Response:

{
  "name1": "value-from-azure",
  "name2": "another-value",
  "source": "Azure App Configuration"
}

Configuration

Azure App Configuration Setup

  1. Create App Configuration Store in Azure Portal
  2. Add Configuration Keys:
    • Key: name1, Value: your-first-value
    • Key: name2, Value: your-second-value
  3. Get Connection String from Azure Portal β†’ Access Keys
  4. Update bootstrap.yml with your connection string

bootstrap.yml Configuration

spring:
  cloud:
    azure:
      appconfiguration:
        stores:
          - connection-string: ${AZURE_APPCONFIG_CONNECTION_STRING}
      credential:
        managed-identity-enabled: false  # Disable if not using managed identity

Environment Variables (Optional)

For production deployments, use environment variables:

# Windows PowerShell
$env:AZURE_APPCONFIG_CONNECTION_STRING="Endpoint=https://..."

# Linux/Mac
export AZURE_APPCONFIG_CONNECTION_STRING="Endpoint=https://..."

Running the Application

Option 1: Maven Spring Boot Plugin (Recommended)

mvn spring-boot:run

Option 2: Packaged JAR

# Build the JAR
mvn clean package

# Run the JAR
java -jar target/nftclubcoin-app-0.0.1-SNAPSHOT.jar

Option 3: IDE

IntelliJ IDEA:

  1. Open the project (File β†’ Open β†’ Select pom.xml)
  2. Right-click on NftClubcoinAppApplication.java
  3. Select "Run 'NftClubcoinAppApplication'"

VS Code:

  1. Install "Extension Pack for Java"
  2. Open the project folder
  3. Press F5 to run

Eclipse:

  1. Import β†’ Existing Maven Project
  2. Right-click project β†’ Run As β†’ Spring Boot App

πŸ§ͺ Testing

Run All Tests

mvn test

Skip Tests During Build

mvn clean install -DskipTests

Manual API Testing

# Test configuration endpoint
curl http://localhost:8080/config

# Test JSON endpoint (MAIN ENDPOINT)
curl http://localhost:8080/config/json

# Test environment endpoint
curl http://localhost:8080/env

# Debug configuration
curl http://localhost:8080/debug

πŸ”§ Troubleshooting

Error: "missing required environment variable AZURE_CLIENT_ID"

Cause: The application is trying to use Managed Identity authentication but the required environment variables are not set.

Solution 1 - Disable Managed Identity (Recommended for local development):

Add to src/main/resources/bootstrap.yml:

spring:
  cloud:
    azure:
      credential:
        managed-identity-enabled: false

Solution 2 - Provide Service Principal Credentials:

# Windows PowerShell
$env:AZURE_CLIENT_ID="your-client-id"
$env:AZURE_CLIENT_SECRET="your-client-secret"
$env:AZURE_TENANT_ID="your-tenant-id"

# Linux/Mac
export AZURE_CLIENT_ID="your-client-id"
export AZURE_CLIENT_SECRET="your-client-secret"
export AZURE_TENANT_ID="your-tenant-id"

Error: "Failed to load configuration from Azure App Configuration"

Solutions:

  1. Verify connection string is correct in bootstrap.yml
  2. Check network connectivity to Azure
  3. Ensure keys exist in Azure App Configuration
  4. Check Azure App Configuration access permissions

Application Won't Start

Check:

  1. Java version: java -version (Must be 11+)
  2. Maven version: mvn -version (Must be 3.6+)
  3. Port 8080 is not in use: netstat -ano | findstr :8080
  4. Build the project: mvn clean install

πŸ’‘ Best Practices

Security

  • βœ… Never commit connection strings to version control
  • βœ… Use environment variables for sensitive data
  • βœ… Use Managed Identity in Azure deployments
  • βœ… Integrate with Azure Key Vault for secrets

Performance

  • βœ… Enable caching for configuration values
  • βœ… Use refresh strategies for dynamic updates
  • βœ… Monitor Azure App Configuration requests

Development

  • βœ… Use different App Configuration stores for each environment
  • βœ… Implement proper error handling
  • βœ… Log configuration loading events
  • βœ… Test with mock configurations locally

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Useful Links

πŸ“ž Support


Built with ❀️ using Spring Boot and Azure

Last Updated: December 2025

Keywords

spring boot azure, azure app configuration, spring cloud azure, java configuration management, azure integration, microservices configuration, cloud native java, spring boot maven, azure spring boot example, centralized configuration, feature flags azure, azure key vault integration

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors