Skip to content

feat: Add support for Azure SQL AAD Users#5104

Open
TheiLLeniumStudios wants to merge 6 commits into
Azure:mainfrom
TheiLLeniumStudios:feat/aad-users-azure-sql
Open

feat: Add support for Azure SQL AAD Users#5104
TheiLLeniumStudios wants to merge 6 commits into
Azure:mainfrom
TheiLLeniumStudios:feat/aad-users-azure-sql

Conversation

@TheiLLeniumStudios

Copy link
Copy Markdown

What this PR does

Adds Azure Active Directory (AAD) user support to the Azure SQL User CRD, enabling token-based authentication for managed identities, service principals, AAD users, and AAD groups.

Changes:

  • Added AADUserSpec to UserSpec with Alias and ServerAdminUsername fields
  • Added webhook validation for mutual exclusivity (LocalUser OR AADUser), type immutability, and alias immutability
  • Created aadUser connector that authenticates using the operator's managed identity via token
  • Updated reconciler to route to appropriate connector based on spec

Example usage:

apiVersion: sql.azure.com/v1
kind: User
metadata:
  name: my-app-identity
spec:
  azureName: my-managed-identity
  owner:
    name: my-database
  aadUser:
    serverAdminUsername: yourAADAdmin
  roles:
    - db_datareader
    - db_datawriter

Closes #3700

How does this PR make you feel?

gif

Checklist

  • this PR contains documentation
  • this PR contains tests
  • this PR contains YAML Samples

@TheiLLeniumStudios TheiLLeniumStudios changed the title Feat/aad users azure sql feat(sql): Add support for Azure SQL AAD Users Jan 13, 2026
@TheiLLeniumStudios

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree


func Test_AzureSQL_AADUser(t *testing.T) {
t.Parallel()
t.Skip("Cannot run in CI currently due to AAD tenant restrictions on CI subscription")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this test can run in our CI subscription - I believe the policy/restriction prohibits local users. We'll check this at our end.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Please let me know after confirming if that's the case, and I'll enable this test

@matthchr matthchr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow response on this - thank you for sending this PR.

Can you share some more details about how you tested this?

resource, ok := obj.(*v1.User)
if !ok {
return fmt.Errorf("expected github.com/Azure/azure-service-operator/v2/api/dbforpostgresql/v1/User, but got %T", obj)
return fmt.Errorf("expected github.com/Azure/azure-service-operator/v2/api/sql/v1/User, but got %T", obj)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, great catch

@@ -0,0 +1,218 @@
---

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should not be here. It should get automatically generated + included in config/crd/generated/bases by our tooling, it doesn't need to be checked in here.

@theunrepentantgeek theunrepentantgeek changed the title feat(sql): Add support for Azure SQL AAD Users feat: Add support for Azure SQL AAD Users Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Feature: Add support for Azure SQL AAD Users

3 participants