0
votes

I was just looking at some of the "AzureRMSQL" powershell commands to manage databases and database servers. The list is here....

https://msdn.microsoft.com/library/azure/mt574084.aspx

There does not seem to be an export command. Am I missing something? The function is there in the new portal so it should be possible.

For non Resource Manager SQL databases there is the command "Start-AzureSqlDatabaseExport" but I dont thinks this works with RM databases.

Thanks Will

2

2 Answers

1
votes

I tried many times with the following commands:

$Credential = Get-Credential
$SqlContext = New-AzureSqlDatabaseServerContext -ServerName $ServerName -Credentials $Credential
$StorageContext = New-AzureStorageContext -StorageAccountName $StorageName -StorageAccountKey $StorageKey
$Container = Get-AzureStorageContainer -Name $ContainerName -Context $StorageContext
$exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $SqlContext -StorageContainer $Container -DatabaseName $DatabaseName -BlobName $BlobName

But when creates a server connection context with New-AzureSqlDatabaseServerContext, the message says the server was not found or was not accessible:

New-AzureSqlDatabaseServerContext : A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that S
QL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
At line:1 char:8
+ $Con = New-AzureSqlDatabaseServerContext -ServerName "derekserver" -C ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureSqlDatabaseServerContext], SqlException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet.NewAzureSqlDatabaseServerContext

So basically we can speculate New-AzureSqlDatabaseServerContext doesn't work with Azure Resource Manager SQL databases.

And no ARM cmdlets with the same function found for now.

0
votes

At first brush this can be a little confusing simply by the absence of the appropriate cmdlet. However SQL server works in a similar way that storage works. Once you have an authentication context the ASM and ARM deployments both use the ASM cmdlets.

In this case you would do something like this

$cred = Get-Credential # sql authentication
$context = New-AzureSqlDatabaseServerContext `
                                -ServerName temp01confuseiosql `
                                -Credential $cred 

$storagecontext = (Get-AzureRmStorageAccount `
                      -ResourceGroupName testrg `
                      -Name teststore01).Context 


Start-AzureSqlDatabaseExport -SqlConnectionContext $context `
                         -StorageContext $storagecontext `
                         -StorageContainerName sql `
                         -DatabaseName testdb `
                         -BlobName $blobname