Skip to content

Cannot create a mssql user across two databases in Azure SQL. #288

@AndrewBorl

Description

@AndrewBorl

What happened?

If you create two user resources for different databases, a requirement for logging in to Azure SQL with contained users, you will get an error creating login that the service principal already exists reconciling the second resource.

The login database and the CREATE LOGIN command is not optional in the reconciler, forcing a CREATE LOGIN for every CREATE USER, but for Azure SQL contained users across multiple databases, you want to run CREATE LOGIN once in the master database, and then CREATE USER in each database the user should have access to.

How can we reproduce it?

Apply CRDS such as:

`apiVersion: mssql.sql.m.crossplane.io/v1alpha1
kind: User
metadata:
name: user1
spec:
forProvider:
database: database1
loginDatabase: master
passwordSecretRef:
key: password
name: somecreds
providerConfigRef:
name: config

apiVersion: mssql.sql.m.crossplane.io/v1alpha1
kind: User
metadata:
name: user1
spec:
forProvider:
database: database2
loginDatabase: master
passwordSecretRef:
key: password
name: somecreds
providerConfigRef:
name: config
`

What environment did it happen in?

Crossplane version: v0.13.0
Kubernetes version: v1.32.7
Kubernetes distribution: Azure AKS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions