如何更改 Azure 资源组的名称?

在新模型实现之后,我所有的网站现在都属于名为“ Default-Web-East”的独立资源组,而我所有的 SQL 数据库都属于名为“ Default-SQL-East”的独立资源组。

这至少可以说是令人困惑的。

我想重新命名这些组,以便有一些语义上的含义。我还希望将关联的 SQL 数据库和网站分组在同一个资源组中。

不过,我也看不出有什么办法。这可能吗?

1)重新命名资源组? 2)将现有的 SQLDB 和网站合并为一个资源组?

62082 次浏览

Edit: You can't rename an Azure Resource Group.

What you can do is move your resources to a new Resource Group instead. Moving all resources in Resource Group A to Resource Group B is the poor man's rename.

Unfortunately not all resource providers let you move resources between resource groups, and some that do might have strings attached that only let you move resources under certain conditions.

For Azure Web Apps (previously called Azure Websites) you can currently only move all the websites related resources in a single invocation. That "all websites related resources" means all resource under the provider "Microsoft.Web". This includes all websites, app hosting platforms, and certificates that are in the source resource group.


Via the portal

When viewing a group's resources, you can use the "Move" tab Screenshot of resource group options in portal

Clicking the "Move" tab will show something this, allowing you to choose or create a new group: The move tab in resource group on Azure portal

Via Azure Powershell

The easiest way to do this is to use the Move-AzureRmResource powershell cmdlet.

The command would look like this:

Get-AzureRmResource -ResourceGroupName <sourceResourceGroupName> | Move-AzureRmResource -DestinationResourceGroupName <destResourceGroupName>

source: https://azure.microsoft.com/en-us/documentation/articles/resource-group-move-resources/


Via Rest API

The other way to do this is to use the MoveResource Rest API or with the ArmClient.

Here's the API call you'll want to make:

POST https://<endpoint>/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/moveResources?api-version={api-version}

Where {resourceGroupName} is the source resource group.

I'm pretty sure the endpoint should be "https://management.azure.com", but if you use the ArmClient the tool will just take care of the endpoint for you.

Request Body:

{
"targetResourceGroup": "/subscriptions/{subscriptionId}/resourceGroups/{targetResourceGroupNameName}",
"resources":
[
"/subscriptions/{id}/resourceGroups/{source}/providers/{namespace}/{type}/{name}",
"/subscriptions/{id}/resourceGroups/{source}/providers/{namespace}/{type}/{name}"
]
}

In addition to the main answer, Azure Portal has a feature of moving the Resources that is allowed to be moved to a new Resource group.

  1. Go to your Resource Group that has Resources you want to move to an existing or a new created Resource Group.
  2. Select the one, multiple or all (1) Resources you want to move and click on the Move (2) bottom as shown in image. (you can select moving to Resources with in the same subscription or to another subscription) A third option if you need just to change the Region) see the the figure at the end.

enter image description here

  1. It will ask you to chose which Resource Group to move to.

Note: This process might take some time, be patient. When done, you will see that the resource disappear from the old one and will be found in the new one. That said some resources might be restricted from been moved to other resources.

enter image description here

Move (Fixing) only region

enter image description here