azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

New-AzureRmSqlDatabaseCopy -Tags not working

Open dalibormesaric opened this issue 8 years ago • 9 comments

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


dalibormesaric avatar Apr 25 '18 09:04 dalibormesaric

@jaredmoo @akromm Can you take a look at this issue?

maddieclayton avatar Apr 25 '18 21:04 maddieclayton

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

jaredmoo avatar Apr 26 '18 00:04 jaredmoo

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!

jaredmoo avatar Apr 26 '18 01:04 jaredmoo

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 avatar Nov 23 '18 17:11 sbgillett

@sbgillett which version of AzureRm.Sql are you using?

jaredmoo avatar Nov 23 '18 17:11 jaredmoo

@jaredmoo 4.11.5

sbgillett avatar Nov 23 '18 17:11 sbgillett

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:

image

It looks like the changelog was incorrectly updated. Can you please try the latest stable version (4.12.1)?

jaredmoo avatar Nov 23 '18 18:11 jaredmoo

@jaredmoo yup - working in 4.12.1 - thanks 👍

sbgillett avatar Nov 27 '18 10:11 sbgillett

Great to hear, thanks!

jaredmoo avatar Nov 27 '18 16:11 jaredmoo