Moving database from On premise to Azure

It may be that you are trying to move your DB from on premise to Azure and using ALTER DATABASE command. Once you make the metadata change using ALTER DATABASE and then move the physical file to AZURE, the DB fails to come online with the following error message:

2014-05-15 04:31:59.370 spid26s      Error: 5120, Severity: 16, State: 142.
2014-05-15 04:31:59.370 spid26s      Unable to open the physical file "". Operating system error 12150: "12150(failed to retrieve text for this error. Reason: 317)".
2014-05-15 04:31:59.420 spid26s      Error: 17207, Severity: 16, State: 1.
2014-05-15 04:31:59.420 spid26s      FileMgr::StartLogFiles: Operating system error 2(The system cannot find the file specified.) occurred while creating or opening file ''. Diagnose and correct the operating system error, and retry th
2014-05-15 04:31:59.420 spid26s      File activation failure. The physical file name "" may be incorrect.


There are two issue here:

1.  When you have moved the files, the files have been moved as block BLOB and not as page Blob. To remove this restriction, you have to make use of API mentioned by PG team to move the files.

2.  There are already files with the same name on the blob container which we have created.


The best option to move the database is to take a backup and then restore it with the move command:

USE master; 


FROM DISK = 'C:\BACKUP\TestDB3Restore.bak'  


MOVE 'TestDB3Restore' TO '',   

MOVE 'TestDB3Restore_log' TO ''; 


Happy Learning & Troubleshooting!!

Disclaimer:  Everything here, is my personal opinion and is not read or approved by Microsoft before it is posted. No warranties or other guarantees will be offered as to the quality of the opinions or anything else offered here.

Comments (0)

Skip to main content