Migrate to Azure Managed Identity for Azure SQL (mi-azuresql-spring) #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new Spring Boot project
mi-azuresql-springthat demonstrates how to connect to Azure SQL Database using Azure Managed Identity authentication, eliminating the need for password-based authentication.Key Changes
1. Spring Boot Project Structure
Created a complete Spring Boot application with:
AzureSqlManagedIdentityApplication.java- Entry point for the Spring Boot applicationDatabaseService.java- Service layer for Azure SQL connectivity with managed identityDatabaseController.java- Exposes endpoints for testing database connectivity2. Maven Configuration (pom.xml)
Added Spring Cloud Azure BOM and dependencies:
3. Managed Identity Configuration (application.properties)
Configured Azure SQL connection with managed identity authentication:
4. REST API Endpoints
The application provides the following endpoints for testing:
GET /api/database/health- Application health checkGET /api/database/test-connection- Test Azure SQL connectivityGET /api/database/version- Get database versionGET /api/database/test-query- Execute a simple test query5. Documentation
Comprehensive README.md with:
Benefits
✅ Security: Eliminates password-based authentication
✅ Azure Native: Uses Azure Managed Identity for seamless authentication
✅ Production Ready: Includes proper error handling, logging, and testing
✅ Easy Testing: REST endpoints for validating connectivity
✅ Documentation: Complete setup and usage instructions
This migration demonstrates best practices for connecting Spring Boot applications to Azure SQL Database using managed identity, providing a secure and maintainable solution for Azure-native applications.
Created from VS Code via the GitHub Pull Request extension.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.