Skip to content

Tags for Restore-AzSqlDatabase not working with the cross subscription restore #18435

@jayendranarumugam

Description

@jayendranarumugam

Description

We are trying to follow this tutorial trying to do the cross subscription

[hashtable]$tags = @{"region" = "eastus2"}


$SourceResourceGroupName = "xxttt"
$SourceSynapseWorkspaceName = "xxyy"
$SourceSqlPoolName = "sxxyy"

$RestorePointLabel = "abc"

$TargetResourceGroupName ="abc"
$TargetServerName = "abc"
$TargetDatabaseName = "ac"



$Sourcesqlpool = Get-AzSynapseSqlPool -ResourceGroupName $SourceResourceGroupName -WorkspaceName $SourceSynapseWorkspaceName -Name $SourceSqlPoolName

Write-Output $Sourcesqlpool


$restorePoint = $Sourcesqlpool | Get-AzSynapseSqlPoolRestorePoint | Where-Object {$_.RestorePointLabel -eq $RestorePointLabel}

Write-Output $restorePoint

$DestinationSubscriptionId = "abc"
Set-AzContext -SubscriptionId $DestinationSubscriptionId

$PointInTime = $RestorePoint.RestorePointCreationDate 

Write-Output $PointInTime



$RestoredDatabase = Restore-AzSqlDatabase -FromPointInTimeBackup -PointInTime $PointInTime `
    -ResourceGroupName $TargetResourceGroupName -Tag $tags `
    -ServerName $TargetServerName -TargetDatabaseName $TargetDatabaseName `
    -ResourceId $Sourcesqlpool.Id -Edition "DataWarehouse" `
    -ServiceObjectiveName "DW100c"

This script was finally failing on Restore-AzSqlDatabase where the tags is not getting applied to the new sqldb

Issue script & Debug output

Resource 'synapsedb' was disallowed by policy. Policy identifiers:
| '[{"policyAssignment":{"name":"Mandate and Audit Tags on Supported Resources}

Environment data

Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19044
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Module versions

enter image description here

Error output

Resource 'synapsedb' was disallowed by policy. Policy identifiers:
| '[{"policyAssignment":{"name":"Mandate and Audit Tags on Supported Resources}

Metadata

Metadata

Assignees

Labels

CXP Attention[Deprecated] The Azure CXP Support Team is responsible for this issue.SQL - Backup & Restorecustomer-reportedquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions