Skip to content

Rename SQL database is inconvenient #4055

@jaredmoo

Description

@jaredmoo

Originally posted at Azure/azure-powershell#3571 (comment):

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);
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions