![](/img/trans.png)
[英]How do I get part of the name of my Azure resource group and use it to create a new Azure resource name?
[英]How do I change the name of an Azure Resource Group?
實施新模型后,我的所有網站現在都屬於名為“Default-Web-East”的單個資源組,而我的所有 SQL 數據庫都屬於名為“Default-SQL-East”的單個資源組。
這至少可以說是令人困惑的。
我想重命名這些組以具有一些語義含義。 我還想將關聯的 SQL 數據庫和網站分組在同一個資源組中。
但是,我也看不出有什么可做的。 這可能嗎?
1) 重命名資源組? 2) 將現有的 SQL 數據庫和網站組合成一個資源組?
編輯:不能重命名 Azure 資源組。
您可以做的是將您的資源移動到一個新的資源組。 將資源組 A 中的所有資源移至資源組 B 是窮人的重命名。
不幸的是,並非所有資源提供者都允許您在資源組之間移動資源,並且有些提供者可能附加了僅允許您在特定條件下移動資源的字符串。
對於 Azure Web 應用程序(以前稱為 Azure 網站),您目前只能在一次調用中移動所有與網站相關的資源。 “所有網站相關資源”是指提供者“Microsoft.Web”下的所有資源。 這包括源資源組中的所有網站、應用托管平台和證書。
通過門戶
通過 Azure Powershell
執行此操作的最簡單方法是使用 Move-AzureRmResource powershell cmdlet。
該命令如下所示:
Get-AzureRmResource -ResourceGroupName <sourceResourceGroupName> | Move-AzureRmResource -DestinationResourceGroupName <destResourceGroupName>
來源: https ://azure.microsoft.com/en-us/documentation/articles/resource-group-move-resources/
另一種方法是使用 MoveResource Rest API 或ArmClient 。
這是您要進行的 API 調用:
POST https://<endpoint>/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/moveResources?api-version={api-version}
其中{resourceGroupName}
是源資源組。
我很確定端點應該是“ https://management.azure.com ”,但是如果您使用ArmClient ,該工具只會為您處理端點。
請求正文:
{ "targetResourceGroup": "/subscriptions/{subscriptionId}/resourceGroups/{targetResourceGroupNameName}", "resources": [ "/subscriptions/{id}/resourceGroups/{source}/providers/{namespace}/{type}/{name}", "/subscriptions/{id}/resourceGroups/{source}/providers/{namespace}/{type}/{name}" ] }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.