1

I am wanting to clone a copy of our production database onto our QA server as part of our continuous integration program.

There doesn't appear to be a method in Azure to clone a database just yet so I am exporting and importing the database via blob storage.

I am having trouble with the following commands (ommiting the unimportant stuff):

$SqlCtx = New-AzureSqlDatabaseServerContext -ServerName $ServerName -UseSubscription
$exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $SqlCtx -StorageContainer $Container -DatabaseName $DatabaseName -BlobName $BlobName

Which returns the following error.

Start-AzureSqlDatabaseExport : Cannot bind parameter 'SqlConnectionContext'. Cannot convert the "Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.ServerDataServiceCertAuth" value of type "Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.ServerDataServiceCertAuth" to type "Microsoft.WindowsAzure.Commands.SqlDatabase.Services.Server.ServerDataServiceSqlAuth".

I am quite sure that this is because I don't have any sql credentials in my subscription so the sql connection doesn't know how to connect. Does anybody know how I can make this work?

jscott
  • 24,484
  • 8
  • 79
  • 100
Jamesla
  • 113
  • 4
  • 1
    I am running into this exact same issue. It seems like you can only do export requests if I use a user name and password, but heck, I don't want those in plain text in some script. –  Dec 18 '14 at 00:54

1 Answers1

2

As you pointed out, you need to provide Sql credentials. One way is to ask the user for credentials using Get-Credential, like in the example for Start-AzureSqlDatabaseExport:

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

Azure Sql server credentials are managed separately from Azure credentials, (just like VM logins), that's why it's not enough to provide Azure subscription credentials.

qbik
  • 123
  • 5