Connecting Azure SQL Database using PowerShell

 

In this post we will connect Azure SQL Database using PowerShell.

I assume that you have a Azure Database Created using Azure Portal and the login information which was provided at the time of database creation.

Import Azure PowerShell Module.

import-module ‘C:Program Files (x86)Microsoft SDKsAzurePowerShellServiceManagementAzureAzure.psd1’

Azure SQL Database can only be accessed using SQL Server Authentication

#Create Azure SQL Database server connection context
# Define a SQL Database server credential – Specify the username, and password in the Popup dialog

 $cred=Get-Credential

image

 

image

$sqlDatabaseServerNameFQDN=’faw5udm867.database.windows.net’

 

image

$ctx=New-AzureSqlDatabaseServerContext -FullyQualifiedServerName $sqlDatabaseServerNameFQDN -Credential $cred

image

Get-AzureSqlDatabase -ConnectionContext $ctx | SELECT Name,CollationName,Edition,MaxSizeGB,Createdate |Format-Table

image

Leave a Reply

Your email address will not be published. Required fields are marked *