Home > SQL Databases > Connecting Azure SQL Database using PowerShell

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 SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.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

Categories: SQL Databases
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: