我有一个应用程序,它在每个租户模型中使用多租户而不是一个数据库。我使用Shardmap跟踪租户数据库的位置。 当我尝试创建一个弹性作业来运行迁移时,我将AzSqlElasticJobTarget设置为我的shardmap数据库,所有程序都运行良好并且创建了作业,但随后该作业失败了,并且出现了以下错误:
Failed to determine members of SqlShardMapTarget (server name '***', server location '***.database.windows.net', database '***', shard map '***'): Data structures for shard map manager persistence do not exist at the target location.
我已经去过数据库了,上面有一个__ShardManagement Scheme,上面有所有分片的信息。
# Create TenantsPoolGroup target group
$TenantsGroup = $JobAgent | New-AzSqlElasticJobTargetGroup -Name 'TargetGroup'
$TenantsGroup | Add-AzSqlElasticJobTarget -ServerName $catalogServerName -ShardMapName $config.CatalogShardMapName -DatabaseName $config.CatalogDatabaseName -RefreshCredentialName $config.JobCredentialName
Write-Output "Creating a new job"
$timestamp = Get-Date -Format o | foreach {$_ -replace ":", "_"}
$timestamp = $timestamp | foreach {$_ -replace "\.", "_"}
$timestamp = $timestamp | foreach {$_ -replace "-", "_"}
$JobName = "Migration-$timestamp"
$Job = $JobAgent | New-AzSqlElasticJob -Name $JobName -RunOnce
Write-Output "Creating job steps"
$SqlText = Get-Content -Path "$PSScriptRoot\script-entities.sql" -Raw
$Job | Add-AzSqlElasticJobStep -Name "step1" -TargetGroupName 'TargetGroup' -CredentialName $config.JobCredentialName -CommandText $SqlText
Write-Output "Start a new execution of the job..."
$JobExecution = $Job | Start-AzSqlElasticJob
答案 0 :(得分:0)
我终于发现,用来访问租户目录的用户没有合适的GRANT来访问SCHEMA :: __ ShardManagement,哈哈,我不好