New-AzureRmSqlDatabaseCopy -Tags not working
Description
New-AzureRmSqlDatabaseCopy ignores -Tags and the new database is created without any tags. I ran the script from powershell window and checked the tags in Azure portal.
Script/Steps for Reproduction
New-AzureRmSqlDatabaseCopy -ResourceGroupName rg-resourcegroupname `
-ServerName sql-servername `
-Tags @{key="value"} `
-DatabaseName sqldb-databasename `
-CopyResourceGroupName rg-resourcegroupname `
-CopyServerName sql-servername `
-CopyDatabaseName sqldb-databasename-copy
Module Version
Get-Module -Name AzureRM -ListAvailable
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 5.7.0 AzureRM
Environment Data
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.16299.251
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.251
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Debug Output
@jaredmoo @akromm Can you take a look at this issue?
Acknowledged. Tags aren't being copied from input model to PUT object at https://github.com/azure/azure-powershell/blob/preview/src/ResourceManager/Sql/Commands.Sql/Replication/Services/AzureSqlDatabaseReplicationAdapter.cs#L107
Tags are also missing from create secondary ( https://github.com/azure/azure-powershell/blob/preview/src/ResourceManager/Sql/Commands.Sql/Replication/Services/AzureSqlDatabaseReplicationAdapter.cs#L167 ) and restore ( https://github.com/azure/azure-powershell/blob/preview/src/ResourceManager/Sql/Commands.Sql/Database%20Backup/Services/AzureSqlDatabaseBackupAdapter.cs#L552 ).
We are currently in the middle of a major update to our cmdlet internals in order to support vcore databases, will fix this after that change lands.
Thanks for reporting this issue!
Any update to this? I've worked around using Set-AzureRmResource to set the tags I want following a copy, but often my scripts hit backend delays and I get errors like
Operation on server 'sqlservername' and database 'databasename' is in progress. Please wait a few minutes before trying again.
CategoryInfo : CloseError: (:) [Set-AzureRmResource], ErrorResponseMessageException
FullyQualifiedErrorId : Conflict,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzureResourceCmdlet
@sbgillett which version of AzureRm.Sql are you using?
@jaredmoo 4.11.5
According to https://github.com/Azure/azure-powershell/blob/preview/src/ResourceManager/Sql/Commands.Sql/ChangeLog.md this was fixed in 4.11.5, but if you look at the released package at https://www.powershellgallery.com/packages/AzureRM.Sql/4.11.5 this change was not included in the release:

It looks like the changelog was incorrectly updated. Can you please try the latest stable version (4.12.1)?
@jaredmoo yup - working in 4.12.1 - thanks 👍
Great to hear, thanks!