Home > SQL Databases > Export Azure SQL Database to Azure Storage

Export Azure SQL Database to Azure Storage

You can export the Azure SQL Database using PowerShell , Azure Portal , Visual Studio,SQL Server Management Studio. In this post i have used PowerShell to export the Azure SQL Database to Azure Storage.(You can also export it to you on-premises local storage)

#————————–Create SQL Server Azure Database Context —————————#

import-module ‘C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1’

#—-Provide the sql login and password whose database will be exported—-#

$cred=Get-Credential

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

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

Get-AzureSqlDatabase -ConnectionContext $Sqlctx | SELECT Name,CollationName,Edition,MaxSizeGB,Createdate |Format-Table –Autosize

#————————–Create Azure Storage Context —————————#

Import-AzurePublishSettingsFile C:\Azure\Azure_credentials_file_2.publishsettings

$subscriptionName = "Free Trial"

$storageAccountName = "dbproxazurestorage"

$storageaccountkey = Get-AzureStorageKey $storageAccountName | %{$_.Primary}

$StorageContainer = Get-AzureStorageContainer -Name containerstorage -Context $StorageCtx

#————————–Initiate Export —————————#

$exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $Sqlctx -StorageContainer $StorageContainer -DatabaseName Rehsosu –BlobName Rehsosu_database_export.bacpac

#————————–Check Export Status—————————#

Get-AzureSqlDatabaseImportExportStatus -Request $exportRequest

image

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: