Azure SQL Server Import database fails with message InternalServerError

Hasan Nofal 0 Reputation points
2025-03-11T08:46:33.9233333+00:00

I am trying to switch from Managed Instance database to SQL Server database. I used sqlpackage to get a bacpac backup of the managed instance DB:

sqlpackage /Action:Import /SourceFile:"{file_path}" /TargetConnectionString:"{conn_str}"

I uploaded the bacpac to Azure Storage container and I went to my SQL server and selected import database and selected the bacpac file. In the deployment page the first step to create the database is successful but the second step "import-without-private-link" has status InternalServerError. Here is the full message:

{
    "status": "Failed",
    "error": {
        "code": "InternalServerError",
        "message": "An unexpected error occured while processing the request. Tracking ID: 'd7050645-9e3a-40f2-86f2-359778e069ff'"
    }
}

Please let me know how I can fix this issue, thanks.

Azure SQL Database
{count} votes

Accepted answer
  1. Saraswathi Devadula 0 Reputation points Microsoft External Staff
    2025-03-11T11:27:06.1333333+00:00

    Hello Hasan Nofal

    Greetings!  

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!  

    Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution.  

    Please click "Accept" the answer as original posters help the community find answers faster by identifying the correct answer.

    Issue: Azure SQL Server Import database fails with message InternalServerError. 

    Resolution: When you tried to import the bacpac locally, you got the following error message:

    "Could not import package.

    Warning SQL72012: The object [PMO_MBRGEA_AMS2021_Archive_PRD-11-03-2025 11_37_39_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.

    Warning SQL72012: The object [PMO_MBRGEA_AMS2021_Archive_PRD-11-03-2025 11_37_39_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.

    Error SQL72014: Framework Microsoft SqlClient Data Provider: Msg 35221, Level 16, State 1, Line 1 Could not process the operation.

    Always On Availability Groups replica manager is disabled on this instance of SQL Server. Enable Always On Availability Groups, by using the SQL Server Configuration Manager. Then, restart the SQL Server service, and retry the currently operation. For information about how to enable and disable Always On Availability Groups, see SQL Server Books Online.

    Error SQL72045: Script execution error. The executed script:

    ALTER DATABASE [$(DatabaseName)]

    ADD FILE (NAME = [XTP_630D847A], FILENAME = N'$(DefaultDataPath)$(DefaultFilePrefix)_XTP_630D847A.mdf') TO FILEGROUP [XTP]; (Microsoft.SqlServer.Dac)"

    This is because the bacpac file was exported from a database that had Always On Availability Group (AG) enabled but in the new database it was disabled.

    To solve the issue, you can enable Enable Always On Availability Groups on the new database server or edit the bacpac file to disable the option:

    1. Rename .bacpac to .zip
    2. Extract it
    3. Open model.xml
    4. Delete the following lines:       
    <Element Type="SqlFilegroup" Name="[XTP]">
               <Property Name="ContainsMemoryOptimizedData" Value="True" />
           </Element>
    
    
    1. Find the new hash of model.xml   
    sha256sum model.xml | awk '{print toupper($1)}'
    
    Get-FileHash .\model.xml -Algorithm 'SHA256' | Select-Object -ExpandProperty Hash
    
    1. Copy the checksum value and open Origin.xml and replace the existing checksum on this line:
       <Checksum Uri="/model.xml">9EA0F06B282D4F42955C78A98822A31AA0ED0225CB131B8759379055A482D01F</Checksum>
      
    
    1. Repackage the files into a .zip
    2. Rename back to .bacpac
    3. Retry the import

    I hope this has been helpful!

    Your feedback is important so please take a moment to accept answers. If you still have questions, please let us know what is needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!

    Accepted answer

    Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.

     

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Hasan Nofal 0 Reputation points
    2025-03-11T10:51:27.71+00:00

    Hello Saraswathi Devadula

    Thanks for your help, I was able to fix the issue. Here are the details for anyone with the same issue.

    When I tried to import the bacpac locally I got the following error message:

    "Could not import package.

    Warning SQL72012: The object [PMO_MBRGEA_AMS2021_Archive_PRD-11-03-2025 11_37_39_Data] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.

    Warning SQL72012: The object [PMO_MBRGEA_AMS2021_Archive_PRD-11-03-2025 11_37_39_Log] exists in the target, but it will not be dropped even though you selected the 'Generate drop statements for objects that are in the target database but that are not in the source' check box.

    Error SQL72014: Framework Microsoft SqlClient Data Provider: Msg 35221, Level 16, State 1, Line 1 Could not process the operation. Always On Availability Groups replica manager is disabled on this instance of SQL Server. Enable Always On Availability Groups, by using the SQL Server Configuration Manager. Then, restart the SQL Server service, and retry the currently operation. For information about how to enable and disable Always On Availability Groups, see SQL Server Books Online.

    Error SQL72045: Script execution error. The executed script:

    ALTER DATABASE [$(DatabaseName)]

    ADD FILE (NAME = [XTP_630D847A], FILENAME = N'$(DefaultDataPath)$(DefaultFilePrefix)_XTP_630D847A.mdf') TO FILEGROUP [XTP]; (Microsoft.SqlServer.Dac)"
    

    This is because the bacpac file was exported from a database that had Always On Availability Group (AG) enabled but in the new database it was disabled.

    To solve the issue, you can enable Enable Always On Availability Groups on the new database server or edit the bacpac file to disable the option:

    1. Rename .bacpac to .zip
    2. Extract it
    3. Open model.xml
    4. Delete the following lines:
         
             <Element Type="SqlFilegroup" Name="[XTP]">
                 <Property Name="ContainsMemoryOptimizedData" Value="True" />
             </Element>
         
      
    5. Find the new hash of model.xml
         sha256sum model.xml | awk '{print toupper($1)}'
      
         Get-FileHash .\model.xml -Algorithm 'SHA256' | Select-Object -ExpandProperty Hash
      
    6. Copy the checksum value and open Origin.xml and replace the existing checksum on this line:
         <Checksum Uri="/model.xml">9EA0F06B282D4F42955C78A98822A31AA0ED0225CB131B8759379055A482D01F</Checksum>
         
      
    7. Repackage the files into a .zip
    8. Rename back to .bacpac
    9. Retry the import
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.