5

我正在尝试将我的一些资源(Azure Web Apps、Azure SQLs、Redis 缓存)从一个资源组移动到另一个资源组。我正在使用 Azure 资源管理器 PowerShell cmdlet。

这是我尝试过的:

PS C:\> Move-AzureResource -DestinationResourceGroupName NewResourceGroup -ResourceId "/subscriptions/someguid/resourceGroups/Default-Web-WestEurope/providers/Microsoft.Web/sites/somesite"

或者:

PS C:\> Get-AzureResource -ResourceName somesite | Move-AzureResource -DestinationResourceGroupName NewResourceGroup

或者:只是Move-AzureResource,按回车键并一一提供参数。

这些命令似乎都不起作用。他们只是什么都不做。没有错误,没有输出。当我将调试首选项更改为时,$DebugPreference = "Continue"我只得到以下内容:

DEBUG: 12:16:06 - MoveAzureResourceCommand begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 12:16:06 - using account id 'my@account.tld'...

请注意,我可以创建新资源组 ( New-AzureResourceGroup)、列出资源组 ( Get-AzureResourceGroup)、列出资源 ( Get-AzureResource) 等。

注意:您必须先调用Switch-AzureMode AzureResourceManager才能使用 cmdlet。身份验证由 完成Add-AzureAccount

我一直参考的文章:

4

5 回答 5

2

阅读这个azure 论坛,他们似乎已经实现了 cmdlet,但并非所有资源都支持被移动。

我们发布了一个新的 powershell cmdlet,用于跨资源组移动资源。并非所有资源都支持,但“主要”资源确实像托管服务、虚拟机和存储帐户。

回顾我所遵循的示例,这确实只使用了虚拟机。因此,基于此,我认为尚不支持网站。对于不受支持的资源没有返回错误或警告这一事实有点糟糕。

于 2015-05-15T10:23:53.413 回答
2

虽然目前并非所有资源都受支持,但我了解当前版本 - 0.9.1 - 确实存在一个错误,这意味着即使是受支持的资源也可能无法移动,并出现问题作者所见的症状。我知道这正在为下一个版本进行工作,但在此期间(作为临时解决方法)之前 2 个版本的先前 powershell cmdlet 版本应该可以正常工作。https://github.com/Azure/azure-powershell/releases

于 2015-05-15T13:51:50.417 回答
1

原始问题在0.9.4 版本中得到修复。我刚试过,它有效。

于 2015-07-17T17:54:29.450 回答
1

供参考。若要使用 Move-AzureResourceGroup 移动 VM,您需要同时移动包含云服务及其所有 VM。例如:

Get-AzureResource -ResourceGroupName OriginalResourceGroup | where { $_.ResourceType -match 'Microsoft.ClassicCompute' } | Move-AzureResource -DestinationResourceGroupName NewResourceGroup

默认情况下,云服务中的资源被放置在与云服务的 DNS 名称同名的资源组中。

于 2015-07-17T17:24:38.997 回答
0

出于某种原因,Azure PowerShell 版本 1.0 无法将 Web 应用程序从一个资源组移动到另一个资源组。如果您按照以下说明操作,您将能够通过 powershell 移动 Web 应用程序。

下载 Azure PowerShell 版本 1。以下说明仅适用于此版本。按顺序键入以下命令。

1) **Login-AzureRmAccount** (a login window will pop up asking for your azure credentials, type them in)
2) **Get-AzureRmResource -ResourceGroupName "NameOfResourceGroup" -ResourceName "WebAppName"** (if you are moving over a website, you will see 2 files, you need the one that is a resource type of Microsoft.Web/sites)
3) **Get-AzureRmResource -ResourceGroupName "NameOfResourceGroup" -ResourceName "WebAppName" -ResourceType "Microsoft.Web/sites"**
4) Assign value 3 to a variable of your name choice. I Chose $a, so **$a = Get-AzureRmResource -ResourceGroupName "NameOfResourceGroup" -ResourceName "WebAppName" -ResourceType "Microsoft.Web/sites"**
5) **Move-AzureRmResource -DestinationResourceGroup "DestinationResourceGroup" -ResourceId $a.ResourceId**
6) It will ask you if you are sure type "Y" and hit enter.
于 2016-01-25T23:17:46.180 回答