3
votes

We are testing the migration from a local SQL Server 2008R2 database to Azure, but have hit a bump in the road.

Process followed, based on SO articles:

  • Installed SQL Server 2012 Client tools
  • Amended DB to remove indexes with a fill factor specified, as well as invalid views and procedures (this was determined by using the Export Data-tier Application tool for SSMS, until it successfully created bacpac file)
  • uploaded the successfully created bacpac file to Azure
  • Went through steps to create new database using import method
  • bacpac file is retrieved from blob storage status shown, but then the following error occurs

BadRequest ;Request Error;Error Status Code:</B> 'BadRequest'</P><P><B>Details: </B>Error encountered during the service operation. ; Exception Microsoft.SqlServer.Management.Dac.Services.ServiceException:Unable to authenticate request; </P></DIV></BODY></html>

Note: error text above was trimmed to exclude URL's as I don't have sufficient points.

I can't seem to find any info on this error or where there may be any additional log details to help determine why it will not import.

As the error mentions unable to authenticate, we also tried doing the following:

  • Created a new user and password on the local DB
  • Used this same new user and password for the definition of the new DB on Azure

This did not make any difference.

Would appreciate if someone could point us in the right direction to get this working, as we would need to replicate this process quite a few times.

Thanks.

2

2 Answers

1
votes

We needed the same thing. Here is some steps that we did and the results:

1) Exporting using SQL Database Migration Tool created by ghuey You can download here: https://sqlazuremw.codeplex.com/ It's a great tool and i really recommend you to try this first. Depends of the complexity of your database, it will work just fine. For us, unfortunately didnt work. So you moved to the next step.

2) DAC Package The 2008 has the option to generate the DACPAC witch creates the structure of the database on Azure and then you can Deploy to Azure by references a connection in the 2008 Studio Managament, Right click on Azure Server, Deploy ... se more details here: http://world.episerver.com/documentation/Items/Upgrading/EPiserver-Commerce/8/Migrating-Commerce-databases-to-Azure/ Well, if this works for you, TRY THIS. It's more easy. For us, unfortunately didnt work. So you moved to the next step.

3) Using an 2012 server to export bacpac and then import into azure This steps requires multiple actions to complete. Here it is:

a. Generate a backup into 2008 and move the file do 2012 server;

b. Restore the backup into 2012;

c. Do some SQL that:

c1. Set all owners of SCHEMAs to DBO. You can use an SQL to move schema like this: ALTER AUTHORIZATION ON SCHEMA::[db_datareader] TO [dbo]

c2. Remove all users that was created by you;

c3. Remove all MS_Description (Extend Properties) of all columns and tables

c4. Drop all constraints (tip: generate a complete script of the database with drop and create option enabled and copy the part of "drop constraint"

c5. We need to removed the fill factor options of the indexes of your database. You can do that re-creating the index (including PK that has clustered index associated). Well to drop every PK Clustered, is not that easy but with a little help of Google you will able do find an script to help you create and drop. Here is the script:

    DECLARE @object_id int;
    DECLARE @parent_object_id int;
    DECLARE @TSQL NVARCHAR( 4000);
    DECLARE @COLUMN_NAME SYSNAME;
    DECLARE @is_descending_key bit;
    DECLARE @col1 BIT;
    DECLARE @action CHAR( 6);

    SET @action = 'DROP';
    --SET @action = 'CREATE';

    DECLARE PKcursor CURSOR FOR
    select kc.object_id , kc .parent_object_id
    from sys.key_constraints kc
    inner join sys .objects o
    on kc.parent_object_id = o.object_id
    where kc.type = 'PK' and o. type = 'U'
    and o.name not in ( 'dtproperties','sysdiagrams' )  -- not true user tables
    order by QUOTENAME (OBJECT_SCHEMA_NAME( kc.parent_object_id ))
            ,QUOTENAME( OBJECT_NAME(kc .parent_object_id));

    OPEN PKcursor ;
    FETCH NEXT FROM PKcursor INTO @object_id, @parent_object_id;

    WHILE @@FETCH_STATUS = 0
    BEGIN
    IF @action = 'DROP'
        SET @TSQL = 'ALTER TABLE '
                    + QUOTENAME (OBJECT_SCHEMA_NAME( @parent_object_id))
                    + '.' + QUOTENAME(OBJECT_NAME (@parent_object_id))
                    + ' DROP CONSTRAINT ' + QUOTENAME(OBJECT_NAME (@object_id))
    ELSE
        BEGIN
        SET @TSQL = 'ALTER TABLE '
                    + QUOTENAME (OBJECT_SCHEMA_NAME( @parent_object_id))
                    + '.' + QUOTENAME(OBJECT_NAME (@parent_object_id))
                    + ' ADD CONSTRAINT ' + QUOTENAME(OBJECT_NAME (@object_id))
                    + ' PRIMARY KEY'
                    + CASE INDEXPROPERTY( @parent_object_id
                                        ,OBJECT_NAME( @object_id),'IsClustered' )
                        WHEN 1 THEN ' CLUSTERED'
                        ELSE ' NONCLUSTERED'
                    END
                    + ' (' ;

        DECLARE ColumnCursor CURSOR FOR
            select COL_NAME (@parent_object_id, ic.column_id ), ic .is_descending_key
            from sys .indexes i
            inner join sys. index_columns ic
            on i .object_id = ic .object_id and i .index_id = ic .index_id
            where i .object_id = @parent_object_id
            and i .name = OBJECT_NAME (@object_id)
            order by ic. key_ordinal;

        OPEN ColumnCursor ;

        SET @col1 = 1 ;

        FETCH NEXT FROM ColumnCursor INTO @COLUMN_NAME, @is_descending_key;
        WHILE @@FETCH_STATUS = 0
        BEGIN
            IF (@col1 = 1 )
                SET @col1 = 0
            ELSE
                SET @TSQL = @TSQL + ',';

            SET @TSQL = @TSQL + QUOTENAME( @COLUMN_NAME)
                        + ' '
                        + CASE @is_descending_key
                            WHEN 0 THEN 'ASC'
                            ELSE 'DESC'
                        END;

            FETCH NEXT FROM ColumnCursor INTO @COLUMN_NAME, @is_descending_key;
        END;

        CLOSE ColumnCursor ;
        DEALLOCATE ColumnCursor ;

        SET @TSQL = @TSQL + ');';

        END;

    PRINT @TSQL;

    FETCH NEXT FROM PKcursor INTO @object_id , @parent_object_id ;
    END;

    CLOSE PKcursor ;
    DEALLOCATE PKcursor ;

c6. Re-create the FKs

c7. Remove all indexes

c8. Re-create all indexes (without the fill factor options)

d. Now, right click on the database on 2012 and export data-tier to Azure Storage in format BACPAC. After finished, import on Azure. It should works :-)

0
votes

For anyone who may stumble across this, we have been able to locate the issue by using the bacpac file to create a new database on the local 2008R2 server, through the 2012 Client tools.

The error relates to a delete trigger that is being fired, which I don't understand why it is being executed, but that's another question.

Hopefully this may help others with import errors on SQL Azure.