How to create an Azure Service Principal for an existing SQL server resource

254 Views Asked by At

I need to create a new Azure Service Principal that will be associated with an existing SQL server resource via PowerShell. An unknown person in the company has done this manually before, and I can see that the SQL server's identity.principalId property is used for the Service Principal's ObjectId. Unfortunately, I have not been able to find documentation for how to create this via PowerShell.

I am aware of the New-AzADServicePrincipal command, and I suspect that the -ApplicationObject property is what I should pass the SQL server info in. I'm wondering if this line of thinking is correct, and how to use -ApplicationObject property to represent my SQL server.

Thanks!

1

There are 1 best solutions below

0
LoganCodes On

Finally found the documentation I was looking for. Using the following command on an existing SQL server seems to implicitly create a Service Principal Identity of the same name as the SQL server

Set-AzSqlServer -ResourceGroupName <resource group> -ServerName <server name> -AssignIdentity