无法导出Azure SQL数据库

时间:2018-06-30 22:41:39

标签: azure-sql-database

当我尝试通过Azure门户中的“导出”按钮导出数据库时,出现以下错误:

Error encountered during the service operation. 
Could not extract package from specified database. 
The element DataSyncEncryptionKey_8d263adb59574052847134070b69d73d is not supported in Microsoft Azure SQL Database v12.

尽管我曾经尝试过DataSync服务,但我从未最终使用过它,现在肯定不使用它。我什至后悔尝试该服务,因为它在数据库中创建了我不知道如何完全删除的架构。

现在,这些模式似乎阻止了我导出数据库。

至少可以很好地解决此错误。但是,最好删除所有DataSync服务的痕迹。

请注意,我已经在以下问题的可接受解决方案中使用了脚本:How to remove SQL Azure Data Sync objects manually。那删除了DataSync模式,但我仍然剩下'dss'和'TaskHosting'模式。

我还尝试了电子邮件支持,这是该线程https://social.msdn.microsoft.com/Forums/azure/en-US/8b68b44b-c98a-4b38-8aab-36a30a7fafd9/the-element-datasyncencryptionkeyid-is-not-supported-in-microsoft-azure-sql-database-v12-when?forum=ssdsgetstarted中公认的解决方案所建议的。那封电子邮件只是反弹了。

此外,如果我进入Azure门户,它将不会显示任何同步组或同步代理。

2 个答案:

答案 0 :(得分:2)

我希望您在继续执行在不存在SQL Data Sync 2.0时创建的那些旧论坛线程上概述的步骤之前,已经问过这个问题。 SQL Data Sync不再处于预览状态,本月进入GA并提供了一个deprovision实用程序。

在安装SQL Agent的计算机上的c:\ program files(x86)\ Microsoft SQL Azure Data Sync目录下,您应该找到一个名为deprovisionUtil.exe的实用程序。如果使用开关/ F运行它,它将删除DSS架构及其所有对象。

如果现在无法实现,请创建支持记录。 Azure支持将清理同步数据库。

答案 1 :(得分:1)

首先,让我感谢@ alberto-morillo的帮助。如果情况有所不同,SQL代理很有可能会工作。

最后,我联系了Azure支持,他们给了我以下脚本。之后一切正常。

declare @n char(1)

set @n = char(10)



declare @triggers nvarchar(max)

declare @procedures nvarchar(max)

declare @constraints nvarchar(max)

declare @views nvarchar(max)

declare @FKs nvarchar(max)

declare @tables nvarchar(max)

declare @udt nvarchar(max)



-- triggers

select @triggers = isnull( @triggers + @n, '' ) + 'drop trigger [' + schema_name(schema_id) + '].[' + name + ']'

from sys.objects

where type in ( 'TR') and name like '%_dss_%'



-- procedures

select @procedures = isnull( @procedures + @n, '' ) + 'drop procedure [' + schema_name(schema_id) + '].[' + name + ']'

from sys.procedures

where schema_name(schema_id) = 'dss' or schema_name(schema_id) = 'TaskHosting' or schema_name(schema_id) = 'DataSync'



-- check constraints

select @constraints = isnull( @constraints + @n, '' ) + 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + ']    drop constraint [' + name + ']'

from sys.check_constraints

where schema_name(schema_id) = 'dss' or schema_name(schema_id) = 'TaskHosting' or schema_name(schema_id) = 'DataSync'



-- views

select @views = isnull( @views + @n, '' ) + 'drop view [' + schema_name(schema_id) + '].[' + name + ']'

from sys.views

where schema_name(schema_id) = 'dss' or schema_name(schema_id) = 'TaskHosting' or schema_name(schema_id) = 'DataSync'



-- foreign keys

select @FKs = isnull( @FKs + @n, '' ) + 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']'

from sys.foreign_keys

where schema_name(schema_id) = 'dss' or schema_name(schema_id) = 'TaskHosting' or schema_name(schema_id) = 'DataSync'



-- tables

select @tables = isnull( @tables + @n, '' ) + 'drop table [' + schema_name(schema_id) + '].[' + name + ']'

from sys.tables

where schema_name(schema_id) = 'dss' or schema_name(schema_id) = 'TaskHosting' or schema_name(schema_id) = 'DataSync'



-- user defined types

select @udt = isnull( @udt + @n, '' ) +

    'drop type [' + schema_name(schema_id) + '].[' + name + ']'

from sys.types

where is_user_defined = 1

and schema_name(schema_id) = 'dss' or schema_name(schema_id) = 'TaskHosting' or schema_name(schema_id) = 'DataSync'

order by system_type_id desc





print @triggers

print @procedures

print @constraints

print @views

print @FKs

print @tables

print @udt



exec sp_executesql @triggers

exec sp_executesql @procedures

exec sp_executesql @constraints

exec sp_executesql @FKs

exec sp_executesql @views

exec sp_executesql @tables

exec sp_executesql @udt



GO

declare @n char(1)

set @n = char(10)

declare @functions nvarchar(max)



-- functions

select @functions = isnull( @functions + @n, '' ) + 'drop function [' + schema_name(schema_id) + '].[' + name + ']'

from sys.objects

where type in ( 'FN', 'IF', 'TF' )

and schema_name(schema_id) = 'dss' or schema_name(schema_id) = 'TaskHosting' or schema_name(schema_id) = 'DataSync'





print @functions

exec sp_executesql @functions

GO



--update

DROP SCHEMA IF EXISTS [dss]

GO

DROP SCHEMA IF EXISTS [TaskHosting]

GO

DROP SCHEMA IF EXISTS [DataSync]

GO

DROP USER IF EXISTS [##MS_SyncAccount##]

GO

DROP ROLE IF EXISTS [DataSync_admin]

GO

DROP ROLE IF EXISTS [DataSync_executor]

GO

DROP ROLE IF EXISTS [DataSync_reader]

GO





declare @n char(1)

set @n = char(10)





--symmetric_keys

declare @symmetric_keys nvarchar(max)

select @symmetric_keys = isnull( @symmetric_keys + @n, '' ) + 'drop symmetric key [' + name + ']'

from sys.symmetric_keys

where name like 'DataSyncEncryptionKey%'



print @symmetric_keys



exec sp_executesql @symmetric_keys



-- certificates

declare @certificates nvarchar(max)

select @certificates = isnull( @certificates + @n, '' ) + 'drop certificate [' + name + ']'

from sys.certificates

where name like 'DataSyncEncryptionCertificate%'



print @certificates



exec sp_executesql @certificates

GO



print 'Data Sync clean up finished'