我正在尝试使用“按需付费”订阅中的Recovery Services保管库进行Azure Resource Manager备份和还原。我正在使用非常简单的代码,据我所知,它是出于MS文档的。我可以获得一个保险库对象,我可以获得一个容器,但是当我尝试从任何容器中获取任何项目时,Get-AzureRmRecoveryServicesBackupItem总是不返回任何内容,即使我知道其中有项目并且Azure RM GUI确认了这一点。 “什么都不返回”意味着如果我将结果赋给变量它是空的/ null,如果我尝试输出到控制台则没有输出。
我有两个不同的订阅,具有不同的保管库,虚拟机和备份项以及来自两台不同的计算机的结果相同。我在一台机器上重新安装了模块,另一台机器上从头开始安装模块。使用-Debug开关为Get-AzureRmRecoveryServicesBackupItem命令显示正在返回的项目,其结果为OK,没有错误。 Powershell代码显示在下面,然后出现-Debug输出。踢球者,这个确切的代码工作于2/7/17,没有开玩笑。我现在关注的是想法,所以任何帮助都会受到赞赏。
更新:我们发现当我们为Get-AzureRmRecoveryServicesBackupContainer使用-FriendlyName参数时会出现问题,但是如果我们通过管道输出| Where-Object {$ _.FriendlyName -eq $ vmName}问题不会发生。我们已经开了一个MSFT案例。
$vaultName = 'somevault'
$resourceGroupName = 'somerg'
$vmName = 'testvm'
$vault = Get-AzureRmRecoveryServicesVault -Name $vaultName -ResourceGroupName $resourceGroupName;
Set-AzureRmRecoveryServicesVaultContext -Vault $vault
$container = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM –Status Registered -FriendlyName $vmName
#output of this cmdlet is empty
Get-AzureRmRecoveryServicesBackupItem –Container $container -Debug
调试输出:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Pragma : no-cache
x-ms-request-id : xxx
x-ms-client-request-id : xxx
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-reads: 14930
x-ms-correlation-request-id : xxx
x-ms-routing-request-id : WESTUS:xxx
Cache-Control : no-cache
Date : Sat, 11 Feb 2017 19:39:07 GMT
Server : Microsoft-IIS/8.0
X-Powered-By : ASP.NET
Body:
{
"value": [
{
"id": "/Subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/VS-xxxxxxxxxxxxx-Group/providers/Microsoft.RecoveryServices/vaults/vault273/backupFabrics/Azure/protectionContainers/IaasVM
Container;iaasvmcontainerv2;VS-xxxxxxxxxxxxx-Group;testvm/protectedItems/VM;iaasvmcontainerv2;VS-xxxxxxxxxxxxx-Group;testvm",
"name": "iaasvmcontainerv2;VS-xxxxxxxxxxxxx-Group;testvm",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
"properties": {
"friendlyName": "testvm",
"virtualMachineId": "/subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/VS-xxxxxxxxxxxxx-Group/providers/Microsoft.Compute/virtualMachines/testvm",
"protectionStatus": "Healthy",
"protectionState": "Protected",
"healthStatus": "Passed",
"healthDetails": [
{
"code": 400239,
"title": "IaasVmHealthGreenDefault",
"message": "Backup pre-check status of this virtual machine is OK.",
"recommendations": []
}
],
"lastBackupStatus": "Completed",
"lastBackupTime": "2017-02-11T15:11:12.2071619Z",
"protectedItemDataId": "70368936803029",
"protectedItemType": "Microsoft.Compute/virtualMachines",
"backupManagementType": "AzureIaasVM",
"workloadType": "VM",
"containerName": "iaasvmcontainerv2;VS-xxxxxxxxxxxxx-Group;testvm",
"sourceResourceId": "/subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/VS-xxxxxxxxxxxxx-Group/providers/Microsoft.Compute/virtualMachines/testvm",
"policyId": "/Subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/resourceGroups/VS-xxxxxxxxxxxxx-Group/providers/Microsoft.RecoveryServices/vaults/vault273/backupPolicies/DailyPolicy",
"policyName": "DailyPolicy",
"lastRecoveryPoint": "2017-02-11T15:12:16.7410628Z"
}
}
]
}
DEBUG: AzureQoSEvent: CommandName - Get-AzureRmRecoveryServicesBackupItem; IsSuccess - True; Duration - 00:00:02.3527163; Exception - ;
答案 0 :(得分:1)
有相同的问题(也在各种PC上)并通过传递不同的参数集来解决它。我没有使用Get-AzureRmRecoveryServicesBackupContainer来获取对容器的引用。相反,我直接使用容器名称调用Get-AzureRmRecoveryServicesBackupItem。这仅在您传递参数-BackupManagementType AzureVM时才有效。
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId <myguid>
Get-AzureRmRecoveryServicesVault -Name "myvaultname" | Set-AzureRmRecoveryServicesVaultContext
$item = Get-AzureRmRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM -Name "myname"
$latestRecoveryPoint = Get-AzureRmRecoveryServicesBackupRecoveryPoint -Item $item | Sort-Object RecoveryPointTime -Descending | Select-Object -First 1
如果省略-Name,则会返回一个包含所有名称的列表。