Skip to main content

Posts

Showing posts from February, 2019

How to Log into Azure SQL with Security Principal

To log into your Azure SQL Database with a Security principal do the following: Create an Azure AD security group Add this AAD group as Azure Administrator to your Azure SQL server  Obtain Access Token Connect to Azure SQL Server with the access token for step #3 use this function # # Based on # https://blogs.technet.microsoft.com/stefan_stranger/2018/06/06/connect-to-azure-sql-database-by-obtaining-a-token-from-azure-active-directory-aad/ # Function Get-AADToken { [CmdletBinding()] [OutputType([string])] PARAM ( [String]$TenantID, [string]$ServicePrincipalId, [securestring]$ServicePrincipalPwd ) Try { # Set Resource URI to Azure Database $resourceAppIdURI = 'https://database.windows.net/' # Set Authority to Azure AD Tenant $authority = 'https://login.windows.net/' + $TenantId $ClientCred = [Microsoft.IdentityModel.Clients.ActiveDirectory.ClientCredential]::new($ServicePrincipalId, $ServicePrincipalPwd) $authContext = [Microsoft.IdentityModel.Clients.Act