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

Get-AzureRMSqlDatabase how to rename a database #3571

Closed
eriksteinebach opened this issue Mar 3, 2017 · 14 comments
Closed

Get-AzureRMSqlDatabase how to rename a database #3571

eriksteinebach opened this issue Mar 3, 2017 · 14 comments
Assignees
Labels
Service Attention This issue is responsible by Azure service team. SQL

Comments

@eriksteinebach
Copy link

eriksteinebach commented Mar 3, 2017

Cmdlet(s)

Get-AzureSqlDatabase
Get-AzureRMSqlDatabase

PowerShell Version

5.1.14986.1000

OS Version

10.0.14986.1000

Description

Get-AzureSqlDatabase contains an argument -NewDatabaseName to rename a database. I am looking for a way to do the same with the Get-AzureRMSqlDatabase command (or any other command within the AzureRM powershell commands). But I cannot find a way to do it? I must be missing something, but I have been googling for 2 hours and I can't find any example.

I want to do this:
Set-AzureSqlDatabase -ServerName $ServerName -DatabaseName $DatabaseName -NewDatabaseName $NewDatabaseName

But than with AzureRM commands, something like:
Get-AzureRMSqlDatabase -ResourceGroupName $ResourceGroupName -ServerName $SeverName -DatabaseName $DatabaseName -????

Edit: Just to clarify, I understand there are other ways to change the database name via powershell, but I can not imagine there is no way in the AzureRM commands. I want to keep my scripts as clean as possible

@eriksteinebach eriksteinebach changed the title Get-AzureRMSqlDatabase Get-AzureRMSqlDatabase how to renaming a database Mar 3, 2017
@eriksteinebach eriksteinebach changed the title Get-AzureRMSqlDatabase how to renaming a database Get-AzureRMSqlDatabase how to rename a database Mar 3, 2017
@cormacpayne cormacpayne added the SQL label Mar 3, 2017
@cormacpayne
Copy link
Member

@akromm Hey Adam, would you mind taking a look at this issue?

@akromm-zz
Copy link
Contributor

@eriksteinebach Unfortunately we do not yet support renaming databases via ARM. Work to enable this is in progress but I do not have an ETA at the moment.

@yatesy
Copy link

yatesy commented Jul 3, 2017

Hi guys, any update on this as I want to use the ARM version of rename as well.

@akromm-zz
Copy link
Contributor

@yatesy Unfortunately the work is still in progress. There are a number of back-end changes that we are working on to enable this. As a temporary work around you will need to use TSQL.

@rfcdejong
Copy link

I also had to apply the work around. Beside that will it also be possible to check if a database exists without listing all databases?

@akromm-zz
Copy link
Contributor

@rfcdejong Through powershell you can use the -DatabaseName parameter in the Get-AzureRmSqlDatabase cmdlet. In TSQL I believe you should be able to use a WHERE clause to filter.

@rfcdejong
Copy link

Haha yes ofcourse, but would be nice to use the generated SqlManagementClient in C# .NET instead of using a release environment definition to pass a variable with the master password into the application during release.

@akromm-zz
Copy link
Contributor

@rfcdejong @jaredmoo jaredmoo/azure-sdk-for-net@510cff3

@mpack7225
Copy link

Any estimate on when will the commandlets be updated for this? Looking for a Set-AzureRMSqlDatabase, similar to the old Set-AzureSqlDatabase that let's you change the name of the database.

@jaredmoo
Copy link
Contributor

It will be in the next release. #5009

@cormacpayne
Copy link
Member

This has been resolved.

@rfcdejong
Copy link

I have it working using the Microsoft.Azure.Management.Sql 1.11.0-preview NuGet package, but it is kinda difficult to call, why isn't it simply a parameter with newName?

This is my code what I have to write now with the new function.
It seems to require a ResourceMoveDefinition.

        public async Task RenameAsync(string resourceGroupName, string serverName, string databaseName, string newName)
        {
            EnsureManagementClients();
            
            var newDefinition = new ResourceMoveDefinition
            {
                Id = $"/subscriptions/{_sqlMgmtClient.SubscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{newName}"
            };

            await _sqlMgmtClient.Databases.RenameAsync(resourceGroupName, serverName, databaseName, newDefinition);
        }

@jaredmoo
Copy link
Contributor

jaredmoo commented Feb 7, 2018

Thanks for the feedback! Since your comment is azure-sdk-for-net, I have opened an issue over there and I am investigating how to fix this.

@jaredmoo
Copy link
Contributor

@rfcdejong the change has been merged into Microsoft.Azure.Management.Sql and will be in the next release (1.13). Thanks again!

@bsiegel bsiegel added the Service Attention This issue is responsible by Azure service team. label Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Service Attention This issue is responsible by Azure service team. SQL
Projects
None yet
Development

No branches or pull requests

8 participants