Reputation: 13
I was trying to make a copy of a database on azure using powershell. I have used "Start-AzureSqlDatabaseCopy" for powershell as descriibed on https://msdn.microsoft.com/en-us/library/ff951631.aspx. But it was failing, and not able to create database copy there. I even tried deleting an existing database using "Remove-AzureSqlDatabase" and saw the same issue.
I have connected to the subscription successfully by using Import-AzurePublishSettingsFile. Verified the connection by providing invalid server and throws the expected exception.
Tried to execute as below
Start-AzureSqlDatabaseCopy -ServerName $SourceServerName -DatabaseName $SourceDatabaseName -PartnerServer $TargetServerName -PartnerDatabase $TargetDatabaseName
Throws the below exception.
Start-AzureSqlDatabaseCopy :https://management.core.windows.net/Id/services/sqlservers/servers/server/databases/database/databasecopies does not exist. Error Code: NotFound At s\Scripts\CreateCIDatabase.ps1:36 char:6 + Start-AzureSqlDatabaseCopy -ServerName $SourceServerName -DatabaseName $Sou ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Start-AzureSqlDatabaseCopy], CommunicationException + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.SqlDatabase.Database.Cmdlet.StartAzureSqlDatabaseCopy
I appreciate If someone can help me on this issue?
similar issue has also been posted https://stackoverflow.com/questions/29004974/azure-powershell-to-create-database-backup
Upvotes: 0
Views: 503
Reputation: 1230
Similar to this thread, it looks like you have not properly set your current subscription to the subscription your database is located on. Try to do the following.
1) Set the subscription to the subscription your database is on.
Set-AzureSubscription -SubscriptionName <Your Subscription Name>
2) Check to make sure your current subscription is the one you want to use.
Get-AzureSubscription -Current
3) Use the DBCopy cmdlet to start your copy.
Start-AzureSqlDatabaseCopy -ServerName <SourceServer> -DatabaseName <SourceDatabaseName> -PartnerServer <TargetServerName> -PartnerDatabase <TargetDatabaseName>
Hope this helps!
Upvotes: 0