This article is contributed. See the original author and article here.

Azure portal Import from BACPAC fails if database schema is large because the number of tables, columns, indexes and views.

 


” BadRequest ErrorMessage: The ImportExport operation with Request Id ‘ed049000-1d74-46bf-9dd6-2375c5d079fa’ failed due to ‘An internal error occurred. Please contact Microsoft support and reference the server name, database name, and operation ID.’..”  

 


SQL Server Management Studio “Import data-Tier application” option fails after some time with an error indicating “not enough memory”

 


If the number of tables, indexes and views is large, import model preparation needs a lot of memory and time.

 

In this case the solution is use SqlPackage.exe with “/p:Storage=File” option 

 


/p: Storage=({File|Memory}) Specifies how elements are stored when building the database model. For performance reasons the default is InMemory. For large databases, File backed storage is required.


Syntax


 


sqlpackage.exe /Action:Export /ssn:tcp:<servername>.database.windows.net,1433 /sdn:<sourcedatabasename>  /su:<username> /sp:<Password> /tf:.export.bacpac /p:Storage=File /d:true /df:.outputlog.log /p:LongRunningCommandTimeout=0

 


SqlPackage.exe /Action:Import /sf:.bacpacfile.bacpac /tsn:<servername>.database.windows.net /tdn:<databasename> /p:Storage=File /tu:<username> /tp:********** /d:true /df:.outputlog.log /p:LongRunningCommandTimeout=0

 


Note that some import steps will take some time (hours) and you could think that process is hang. You can use Windows “Resource Monitor” and monitor Sqlpackage.exe disk activity.

 

Note: This solution also applies to export operations

 



 

Regards, Paloma.-

 

Brought to you by Dr. Ware, Microsoft Office 365 Silver Partner, Charleston SC.