question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot copy a source database in an elastic pool to another server with no elastic pool

See original GitHub issue

I need to copy a SQL Database in an elastic pool on one server to another server without an elastic pool. However, the following code fails, noting that the elastic pool name of the source database does not exist on the target server.

let copyDatabase =
    targetSqlServer.Databases.Define(target.Name)
        //.WithServiceObjective("P1") // Using 1.4.0
        //.WithStandardEdition(SqlDatabasePremiumServiceObjective.P1)  // Using 1.8.0
        .WithSourceDatabase(sourceDatabase)
        .WithMode(CreateMode.Copy)
        .Create()

As you can see above, I tried to work around this by using the WithStandardEdition (also tried the WithServiceObjective) method. However, these return an interface that is not compatible with then specifying a source database. New-AzureRmSqlDatabaseCopy allows specifying either a target service objective or elastic pool, so I expected the .NET Azure libraries would allow this as well.

This issue exists in versions 1.4.0 and 1.8.0.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
milismsftcommented, Apr 2, 2018

Hi @panesofglass the Azure SQL management service is inconsistent in regards to when setting a service objective while copying a database is allowed and when is not. I was able to successfully copy a SQL database within a premium Elastic Pool to a different SQL server also setting the service objective if the Elastic Pool edition is Premium. Any other edition settings seems to trigger a service error when invoking the createOrUpdate(). Having this inconsistency makes it difficult to model it in the Fluent .NET SDK. I can suggest an work around for now while I will try to see what can be done for v1.9:

var tempStage = sqlServer.Databases.Define("dbCopyName")
    .WithServiceObjective(ServiceObjectiveName.P1);

var dbCopyResult = ((Microsoft.Azure.Management.Sql.Fluent.SqlDatabaseOperations.Definition.IWithAllDifferentOptions)tempStage)
    .WithSourceDatabase(dbSource)
    .WithMode(CreateMode.Copy)
    .Create();
0reactions
roofiqcommented, Apr 22, 2020

Hello, is there any known compatibility issue between database in elastic pools and standalone server? I have issue when migrating one database in that way and it fails when updating.

Here is description: https://github.com/MicrosoftDocs/azure-docs/issues/51784

Read more comments on GitHub >

github_iconTop Results From Across the Web

Manage multiple databases with elastic pools - Azure SQL ...
Create a new SQL Database elastic pool by using the Azure portal · Go to the Azure portal to create an elastic pool....
Read more >
Can't copy a SQL database from Azure portal - Microsoft Q&A
Hi, I'd like to copy a SQL database to create another with the same ... As you can see, the copied database will...
Read more >
Error when trying to copy a database from an elastic pool ...
This works for every other database I try and copy but returns this error when I try and do it for database stored...
Read more >
Four different methods to copy your Azure SQL database
Type in the database name; Target server; Choose “Yes” if you want to host it in the elastic database pool. If not, leave...
Read more >
Deploy Azure SQL Elastic Pools for Azure SQL Database
Suppose you have an existing database in Azure SQL Server that is not part of the elastic pool. You can add that database...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found