Complete Azure Managed Identity migration for Azure SQL authentication #6
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 completes the migration of the
mi-sql-public-demoproject to use Azure Managed Identity for Azure SQL Database authentication, fixing several issues in the existing partial implementation.Changes Made
Fixed Connection String Construction
The original implementation had a critical bug where connection string parameters were being duplicated, resulting in malformed URLs with double semicolons:
Improved Configuration Management
AZURE_SQLDB_CONNECTIONSTRINGproperty and standardized on the Spring-stylespring.datasource.url${AZ_DATABASE_SERVER_NAME}and${AZURE_CLIENT_ID}placeholders from environment variablesmsiClientIdparameter when using placeholder valuesKey Technical Improvements
Added Comprehensive Testing
Created
MainSQLTest.javawith tests that validate:Validation
The migration has been tested in multiple scenarios:
Development mode (without environment variables):
java -jar target/demo-1.0-SNAPSHOT.jar # Uses placeholder values, connection string properly formattedProduction mode (with environment variables):
AZ_DATABASE_SERVER_NAME=myserver AZURE_CLIENT_ID=myclientid java -jar target/demo-1.0-SNAPSHOT.jar # Resolves placeholders and includes msiClientId parameterDependencies
The project already included:
This PR ensures these dependencies are properly utilized with correct configuration and robust connection string handling.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
myserver.database.windows.netjava -jar target/demo-1.0-SNAPSHOT.jar(dns block)test-server.database.windows.netjava -jar target/demo-1.0-SNAPSHOT.jar(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Created from VS Code via the GitHub Pull Request extension.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.