Reputation: 2158
How can we add AAD to Azure SQL Database using C#. Is there a NuGet package? https://azure.microsoft.com/en-gb/documentation/articles/sql-database-aad-authentication/
Upvotes: 0
Views: 1586
Reputation: 31
Here is an example of the azure-sdk-for-net nuget being used by Azure PowerShell. This will show you how to get the tenant id and the Sid which is the Object Id of the Azure Active Directory user or group. Here is additional example of using the graph client in Azure PowerShell Active Directory Cmdlets.
Upvotes: 2
Reputation: 2158
Services.ServerAdministrators might work
https://github.com/Azure/azure-sdk-for-net/commit/7ca2d576d6e74ad1a18434f16146076ed1b384d4
You need to provide the Tenant ID and SID for the AD user. Not sure how to get this yet. I guess the Graph API.
Also, the admin parameter needs to be client.ServerAdministrators.CreateOrUpdateAsync(resourceGroupName, sqlServerName, "activeDirectory",
Upvotes: 0
Reputation: 628
Connecting to a Microsoft SQL Server – on-premise or SQL Azure does not require NuGet packages. Just use ADO.NET, which is part of the base class library. .NET framework version 4.6 is required.
To use Azure Active Directory integration (a preview feature) your first need to configure Azure AD and the SQL Azure instance
Then use ADO.NET as usual and use a trusted connection like so in the connection string
Data Source=youdatabase.database.windows.net; Authentication=Active Directory Integrated;
The web server must run in context of a user created in your Azure AD tenant.
Azure AD integration is not yet supported for Azure WebSites.
Upvotes: -1