Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CONTROL DATABASE issue when migrating SQL database to Azure

I'm following this tutorial on Microsoft Docs. I've reached the part where I use the "Data Migration Assistant", but after selecting the target Azure database and clicking "Next", I get the following error:

An unexpected error occurred. Current principal does not have CONTROL permission on securable AzureDatabaseName of class DATABASE.

I'm using the only user of the Azure SQL server - the server admin, which should have all permissions. I've verified that the user is 'db_owner' by using IS_ROLEMEMBER.

Am I missing something?

like image 394
Kostadin Mandulov Avatar asked Sep 11 '17 10:09

Kostadin Mandulov


People also ask

What is the difference between SQL Server and SQL database in Azure?

SQL virtual machines offer full administrative control over the SQL Server instance and underlying OS for migration to Azure. The most significant difference from SQL Database and SQL Managed Instance is that SQL Server on Azure Virtual Machines allows full control over the database engine.

Can we migrate on-premises SQL database to Azure?

You can migrate existing SQL Server databases running on: SQL Server on-premises. SQL Server on Azure Virtual Machines. Amazon Web Services (AWS) Elastic Compute Cloud (EC2).

Why do people choose to migrate to Azure MySQL database?

About Azure Database for MySQL This relational database system offers high data protection with enterprise-grade security and support for virtually all regulatory compliance standards. It also provides common cloud benefits such as pay-as-you-go pricing and cost optimization controls.


3 Answers

I had the same issue. This seems to be a bug in Azure SQL databases. If you have dots in the database name it does not work. I replaced the dots with slashes and it worked for me.

You do not need to recreate the database. A rename worked fine for me:

  1. You have to make sure, that no-one else is using the database!
  2. Connect to master table and execute the following script on the Azure SQL Server:

    USE master;
    GO
    ALTER DATABASE [my.database] Modify Name = [my-database] ;
    GO

Here is a link on how to rename Azure SQL databases:

https://learn.microsoft.com/en-us/sql/relational-databases/databases/rename-a-database

like image 194
stoeren Avatar answered Oct 10 '22 21:10

stoeren


Also make sure to create a firewall rule for your incoming connection. This error can be a bit of a red herring.

like image 38
d.elish Avatar answered Oct 10 '22 20:10

d.elish


I deleted everything - the database, the sql server, and the resource group. Then I recreated everything using the same names, except the database name - which previously contained dots - and this time the migration tool worked. I guess I just encountered some bug.

like image 1
Kostadin Mandulov Avatar answered Oct 10 '22 21:10

Kostadin Mandulov