Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jayendranarumugam opened this issue Jun 8, 2022 · 13 comments
Assignees
Labels
customer-reported CXP Attention [Deprecated] The Azure CXP Support Team is responsible for this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that SQL - Backup & Restore

Comments

@jayendranarumugam
Copy link
Contributor

jayendranarumugam commented Jun 8, 2022

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}
@jayendranarumugam jayendranarumugam added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jun 8, 2022
@ghost ghost added customer-reported and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Jun 8, 2022
@jayendranarumugam
Copy link
Contributor Author

jayendranarumugam commented Jun 8, 2022

ref #17474

fyi, this issue is not occuring for Restore-AzSynapseSqlPool

e.g,

Restore-AzSynapseSqlPool -FromRestorePoint -RestorePoint $restorePoint.RestorePointCreationDate -TargetSqlPoolName $TargetSqlPoolName -ResourceGroupName $TargetResourceGroupName -WorkspaceName $TargetSynapseWorkspaceName -ResourceId $sourcesqlpooldatabaseId -PerformanceLevel $PerformanceLevel -Tag $tags

@dingmeng-xue
Copy link
Member

@jayendranarumugam , it seems the message comes from policy setting. Please do below 2 steps and provide more information.
2. Enable debug log via $DebugPreference = "Continue"
3. Call Restore-AzSqlDatabase again and check the log.

You can see the request and response on PowerShell console. Please share the information to us.

@dingmeng-xue dingmeng-xue added SQL - Backup & Restore CXP Attention [Deprecated] The Azure CXP Support Team is responsible for this issue. labels Jun 9, 2022
@ghost
Copy link

ghost commented Jun 9, 2022

Thank you for your feedback. This has been routed to the support team for assistance.

@jayendranarumugam
Copy link
Contributor Author

Here you go @dingmeng-xue . If you see the PUT Request is missing to pass the Tag property from the powershell command

HTTP Method:
PUT

Absolute Uri:
https://management.azure.com/subscriptions/xxxx/resourceGroups/rg/providers/Microsoft.Sql/servers/xxxx/databases/itsynapsedb?api-version=2021-05-01-preview

Headers:
x-ms-client-request-id        : 4e0d3dc1-1f9a-488f-91e3-3edcb7145b9c
Accept-Language               : en-US

Body:
{
  "sku": {
    "name": "DW100c",
    "tier": "DataWarehouse"
  },
  "properties": {
    "createMode": "PointInTimeRestore",
    "restorePointInTime": "2022-06-08T18:08:16Z",
    "sourceResourceId": "/subscriptions/xxxcx/providers/Microsoft.Synapse/workspaces/synapsews01/sqlPools/synapsedb"
  },
  "location": "eastus2"
}

azure-sdk pushed a commit to azure-sdk/azure-powershell that referenced this issue Jun 21, 2022
[Hub Generated] Review request for Microsoft.Media to add version stable/2021-11-01 (Azure#18435)

* Copy 2021-06-01 Account service files to 2021-11-01 folder with version change. can be ignored for review.

* Update account service with the latest 2021-11-01 version with breaking change.

* Add missing examples

* fix tag name

* add type array to the privateEndpointConnections.
@jayendranarumugam
Copy link
Contributor Author

Hi @dingmeng-xue , Is there any update on the issue ? We are currently unable to move forward with this bug. Is there any workaround for this ?

@navba-MSFT navba-MSFT self-assigned this Jul 15, 2022
@navba-MSFT
Copy link
Contributor

@jayendranarumugam Apologies for the late reply. Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

@navba-MSFT
Copy link
Contributor

@jayendranarumugam Could you please check and confirm if you have any Azure Policies configured in your subscription ? This error seems to be due to the Azure Policy which is blocking the resource creation due to incorrect tags.

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

@navba-MSFT navba-MSFT added question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-author-feedback More information is needed from author to address the issue. and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Jul 15, 2022
@jayendranarumugam
Copy link
Contributor Author

Yes we have a policy to prevent from resources that doesn't have any tags. That why we are trying to restore the db along with the tags however looks like the tags we are given is not pass through the API . As i put here #18435 (comment)

@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Jul 15, 2022
@navba-MSFT
Copy link
Contributor

@jayendranarumugam Could you please confirm if you are using 3.10.0 version of the Az.SQL module ? If not, Could you please upgrade your Az.SQL module to this version and test again ? Awaiting your reply.

@navba-MSFT navba-MSFT added needs-author-feedback More information is needed from author to address the issue. and removed needs-team-attention This issue needs attention from Azure service team or SDK team labels Jul 15, 2022
@navba-MSFT
Copy link
Contributor

@jayendranarumugam I wanted to do quick follow-up to check if you had a chance to look at my above comment. Please let us know if you are facing the same issue after upgrading to 3.10.0 version of the Az.SQL module. Awaiting your reply.

@jayendranarumugam
Copy link
Contributor Author

Yep will test this today and let you know

@ghost ghost added needs-team-attention This issue needs attention from Azure service team or SDK team and removed needs-author-feedback More information is needed from author to address the issue. labels Jul 18, 2022
@jayendranarumugam
Copy link
Contributor Author

@navba-MSFT I can see this was fixed with #18475 and working as expected now. Feel free to link/close this issue

@navba-MSFT
Copy link
Contributor

@jayendranarumugam Thanks for getting back. We will now proceed with closure of this GitHub issue. If you need any further assistance on this issue in future, please feel free to reopen this thread. We would be happy to help.

@navba-MSFT navba-MSFT removed the needs-team-attention This issue needs attention from Azure service team or SDK team label Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported CXP Attention [Deprecated] The Azure CXP Support Team is responsible for this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that SQL - Backup & Restore
Projects
None yet
Development

No branches or pull requests

3 participants