{"id":15430511,"url":"https://github.com/lenisha/spring-sql-msi","last_synced_at":"2025-11-09T07:30:34.232Z","repository":{"id":116070914,"uuid":"253896180","full_name":"lenisha/spring-sql-msi","owner":"lenisha","description":"Azure SQL MSI connction from Java on K8S AAD Pod Identity","archived":false,"fork":false,"pushed_at":"2020-04-17T17:28:16.000Z","size":131,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-18T06:16:06.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lenisha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-07T19:47:25.000Z","updated_at":"2020-04-26T16:14:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"adf2c635-585c-4614-a488-8d59db66f0b8","html_url":"https://github.com/lenisha/spring-sql-msi","commit_stats":{"total_commits":9,"total_committers":2,"mean_commits":4.5,"dds":0.2222222222222222,"last_synced_commit":"89cf6e290866d8ffaa7a042c98e1576ca2e5a92c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fspring-sql-msi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fspring-sql-msi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fspring-sql-msi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenisha%2Fspring-sql-msi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lenisha","download_url":"https://codeload.github.com/lenisha/spring-sql-msi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239571542,"owners_count":19661164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T18:16:46.840Z","updated_at":"2025-11-09T07:30:34.200Z","avatar_url":"https://github.com/lenisha.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MSI Auth with Azure Managed Identity\n\n- Create MI and assign to PodIdentity or VM\n- Assign Managed Identity to SQL Admin (or Group) \n\n```\naz sql server ad-admin create --display-name odbcidentity --object-id \u003cMI objectid\u003e --resource-group aks-tests --server testmetoday    \n{\n  \"id\": \"/subscriptions/xxxxx/resourceGroups/aks-tests/providers/Microsoft.Sql/servers/testmetoday/administratorOperationResults/ActiveDirectory\",\n  \"location\": \"West Central US\",\n  \"login\": \"odbcidentity\",\n  \"name\": \"ActiveDirectory\",\n  \"resourceGroup\": \"aks-tests\",\n  \"sid\": \"xxx\",\n  \"tenantId\": \"xxx\",\n  \"type\": \"Microsoft.Sql/servers/administrators\"\n}\n```\nAfter creation verify that identity was added automatically to `master` database users\n\n![docs](./identiy.png)\n\n- set connection string in the `application.properties` with `authentication=ActiveDirectoryMSI;msiClientId=\u003cMI appid\u003e`\n```\nspring.datasource.url=jdbc:sqlserver://testmetoday.database.windows.net:1433;database=testae;authentication=ActiveDirectoryMSI;msiClientId=\u003cMI app id\u003e;Encrypt=true;TrustServerCertificate=false;HostNameInCertificate=*.database.windows.net;loginTimeout=30\n```\n\n- build and run\n```\nmvn package -DskipTests=true\njava -jar target/sqlmsi-0.0.1-SNAPSHOT.jar \n```\n\nit will print logged in User\n```\nationTaskExecutor'\n2020-04-07 21:15:34.757  INFO 2725 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''\n2020-04-07 21:15:34.759  INFO 2725 --- [           main] com.msft.sqlmsi.SqlmsiApplication        : Started SqlmsiApplication in 6.823 seconds (JVM running for 7.392)\nYou have successfully logged on as: e8e422cc-2bb7-xxxx-xxxx-cff38b07a026@72f988bf-86f1-41af-91ab-2d7cd011db47\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenisha%2Fspring-sql-msi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flenisha%2Fspring-sql-msi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenisha%2Fspring-sql-msi/lists"}