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.

Error copying SQL database within Elastic Pool

See original GitHub issue

From @martijnkamphuis on September 12, 2017 11:24

First, let me sketch my situation (resource type - resource name). All resources are in one resource group:

  • SQL server - sql_server_A — Elastic Pool - elastic_pool_1 ----- database - template_db

  • SQL server - sql_server_B (no elastic pools or existing databases)

  • SQL server - sql_server_C — Elastic Pool - elastic_pool_2

  • SQL server - sql_server_D — Elastic Pool - elastic_pool_1 (name equal to Elastic Pool from sql_server_A)

Code being used:

ISqlDatabase template_db = /* Template database obtained from source server */;
ISqlServer sqlTargetServer = /* SQL server instance obtained */;
var dbDefinition = sqlTargetServer.Databases.Define("db_from_template");
var db = await dbDefinition.WithSourceDatabase(template_db)
			.WithMode(CreateMode.Copy)
			.CreateAsync();

I am trying to copy my ‘template_db’ from ‘sql_server_A’ to any of the other SQL servers. What works is copying either to the same SQL server (sql_server_A), or to a different SQL server containing an Elastic Pool with the name equal to the one where the template database is linked to (sql_server_D, elastic_pool_1).

In the other cases (copy to sql_server_B or sql_server_C), an exception is thrown:

{"Long running operation failed with status 'Failed'."}
   at Microsoft.Rest.Azure.AzureClientExtensions.<GetLongRunningOperationResultAsync>d__1`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Rest.Azure.AzureClientExtensions.<GetLongRunningOperationResultAsync>d__0`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Rest.Azure.AzureClientExtensions.<GetPutOrPatchOperationResultAsync>d__4`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.Sql.Fluent.DatabasesOperations.<CreateOrUpdateWithHttpMessagesAsync>d__13.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.Sql.Fluent.DatabasesOperationsExtensions.<CreateOrUpdateAsync>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.Sql.Fluent.SqlDatabaseImpl.<CreateChildResourceAsync>d__87.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.ResourceManager.Fluent.Core.IndependentChildImpl`7.<CreateResourceAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.ResourceManager.Fluent.Core.ResourceActions.Creatable`4.<Microsoft-Azure-Management-ResourceManager-Fluent-Core-ResourceActions-IResourceCreator<IResourceT>-CreateResourceAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.ResourceManager.Fluent.Core.DAG.CreatorTaskItem`1.<ExecuteAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.Management.ResourceManager.Fluent.Core.DAG.TaskGroupBase`1.<ExecuteNodeTaskAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Test.AzureService.<CopyDatabase>d__9.MoveNext() in C:\xxx\Test\AzureService.cs:line 132

In the Azure portal, it is possible to copy the database to a target server AND configure the Elastic Pool or DatabaseEdition/pricing tier. These options are not available in the Fluent SDK when using .WithSourceDatabase and/or .WithMode. I believe this should be added.

Copied from original issue: Azure/azure-sdk-for-net#3684

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
johnverbiestcommented, Mar 29, 2018

Hi,

Using v1.8, I still get this error:

afbeelding

This is the code I’ve used:

var db = azure.SqlServers.Databases.Define($"{sourceDb}_{targetPostfix}")
		.WithExistingSqlServer(testserver)
		.WithExistingElasticPool(targetElasticPool)
		.WithSourceDatabase(origineledatabase.Id)
		.WithMode(CreateMode.Copy)
		.Create();

The source database is in an elasticpool named prodpool1, the target is named migrationpool. The source pool is a standard pool, the target is a premiumRS pool.

Thanks!

0reactions
hovsepmcommented, Apr 23, 2018

closed as dupe of #244

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Azure SQL Database throwing error 1132 "The elastic pool ...
But the insert statement fails with the error message: Msg 1132, Level 16, State 1, Line 1 The elastic pool has reached its...
Read more >
Creating a Copy of Database in Azure SQL DB
Let us learn about how to create a copy of the database in Azure SQL DB. ... This will yield in a syntax...
Read more >
Four different methods to copy your Azure SQL database
To copy the database in Azure uses geo-replication technology. ... Choose “Yes” if you want to host it in the elastic database pool....
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