0

I feel like I must be doing something terribly, terribly wrong. Either that or the documentation on these cmdlets aren't clear enough for me.

What I'm trying to accomplish: I want to use PS to query Azure about the status of our on premise files and folders backups.

I have no issues with logging into the account or any trouble with getting a list of our vaults. The problems start when I set the vault context and try to get information about the backup jobs. The commands that I run:

Login-AzureRmAccount
$Vault = Get-AzureRmRecoveryServicesVault -Name VaultName
Set-AzureRmRecoveryServicesVaultContext -Vault $Vault
Get-AzureRmRecoveryServicesBackupJob -BackupManagementType MARS

The last command returns nothing at all. However, if I enable -Debug on it, it will show all the information I'm interested in under the HTTP RESPONSE header. None of this information is returned, the debugger states that "Number of jobs fetched: 0" and I get nothing.

Full debug output:

DEBUG: 08:44:46 - GetAzureRmRecoveryServicesBackupJob begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 08:44:49 - using account id 'ACCOUNT'...
DEBUG: Inside Restore. Going to create ResourceClient.
DEBUG: [Common.Authentication]: Authenticating using Account: 'ACCOUNT', environment: 'AzureCloud', tenant: 'c2b9e5a3-3e84-41a4-9bb0-9ad0bfc0d078'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - AcquireTokenHandlerBase: === Token Acquisition started:
  Authority: https://login.microsoftonline.com/
  Resource: https://management.core.windows.net/
  ClientId: CLIENT-ID
  CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (2 items)
  Authentication Target: User


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: 42.1826836416667 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: A matching item (access token or refresh token or both) was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
  Access Token Hash: 6f4Gz6d8ZDrYUvYCBBJYPmTnIndSq/HrCDh/o4NT0lk=
  Refresh Token Hash: hF89CiReJHwVRutZTWzsVTGSrcO6vmk+GTYU1Q/jxQQ=
  Expiration Time: 02/22/2018 08:27:00 +00:00
  User Hash: dt37+xi+2YPdIjxWZVMf7Xx5vD6t7he78R4CLmJoH78=


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49:  - TokenCache: Serializing token cache with 2 items.

DEBUG: Client Created successfully
DEBUG: Filters provided are: StartTime -  EndTime -  Status -  Operation -  Type - MARS
DEBUG: [Common.Authentication]: Authenticating using Account: 'ACCOUNT', environment: 'AzureCloud', tenant: 'c2b9e5a3-3e84-41a4-9bb0-9ad0bfc0d078'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - AcquireTokenHandlerBase: === Token Acquisition started:
  Authority: https://login.microsoftonline.com/c2b9e5a3-3e84-41a4-9bb0-9ad0bfc0d078/
  Resource: https://management.core.windows.net/
  ClientId: CLIENT-ID
  CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (2 items)
  Authentication Target: User


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: 42.18256378 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: A matching item (access token or refresh token or both) was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
  Access Token Hash: 6f4Gz6d8ZDrYUvYCBBJYPmTnIndSq/HrCDh/o4NT0lk=
  Refresh Token Hash: hF89CiReJHwVRutZTWzsVTGSrcO6vmk+GTYU1Q/jxQQ=
  Expiration Time: 02/22/2018 08:27:00 +00:00
  User Hash: dt37+xi+2YPdIjxWZVMf7Xx5vD6t7he78R4CLmJoH78=


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49:  - TokenCache: Serializing token cache with 2 items.

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - AcquireTokenHandlerBase: === Token Acquisition started:
  Authority: https://login.microsoftonline.com/c2b9e5a3-3e84-41a4-9bb0-9ad0bfc0d078/
  Resource: https://management.core.windows.net/
  ClientId: CLIENT-ID
  CacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (2 items)
  Authentication Target: User


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: Looking up cache for a token...

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: An item matching the requested resource was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: 42.1825471016667 minutes left until token in cache expires

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - TokenCache: A matching item (access token or refresh token or both) was found in the cache

DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49: TOKEN - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned:
  Access Token Hash: 6f4Gz6d8ZDrYUvYCBBJYPmTnIndSq/HrCDh/o4NT0lk=
  Refresh Token Hash: hF89CiReJHwVRutZTWzsVTGSrcO6vmk+GTYU1Q/jxQQ=
  Expiration Time: 02/22/2018 08:27:00 +00:00
  User Hash: dt37+xi+2YPdIjxWZVMf7Xx5vD6t7he78R4CLmJoH78=


DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : 
DEBUG: 02/22/2018 07:44:49:  - TokenCache: Serializing token cache with 2 items.

DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/Subscriptions/SUB-ID/resourceGroups/RSV_West-Europe/providers/Microsoft.RecoveryServices/vaults/VAULTNAME/backupJobs?$filter=operation eq '' and startTime eq '2018-02-21 07:44:49 AM' and endTime eq '20
18-02-22 07:44:49 AM'&api-version=2017-07-01

Headers:
x-ms-client-request-id        : 5bce331b-e74a-4b23-a41a-8dff4f7dd890
accept-language               : en-US

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Pragma                        : no-cache
x-ms-request-id               : fa17789f-af7f-44eb-99c7-8d3dfca6d676
x-ms-client-request-id        : f0a8eed2-febe-4ca6-b748-d6dc9f2b2b00-PS,f0a8eed2-febe-4ca6-b748-d6dc9f2b2b00-PS
Strict-Transport-Security     : max-age=31536000; includeSubDomains
Cache-Control                 : no-cache
Server                        : Microsoft-IIS/8.0,Microsoft-IIS/8.0
X-Powered-By                  : ASP.NET
X-Content-Type-Options        : nosniff
x-ms-ratelimit-remaining-subscription-reads: 14998
x-ms-correlation-request-id   : fa17789f-af7f-44eb-99c7-8d3dfca6d676
x-ms-routing-request-id       : WESTEUROPE:20180222T072714Z:fa17789f-af7f-44eb-99c7-8d3dfca6d676
Date                          : Thu, 22 Feb 2018 07:27:13 GMT

Body:
{
  "value": [
    {
      "id": "/Subscriptions/SUB-ID/resourceGroups/RSV_West-Europe/providers/Microsoft.RecoveryServices/vaults/VAULTNAME/backupJobs/JOB-ID",
      "name": "JOB-ID",
      "type": "Microsoft.RecoveryServices/vaults/backupJobs",
      "properties": {
        "jobType": "MabJob",
        "duration": "PT24M50.092S",
        "mabServerName": "SERVERNAME",
        "mabServerType": "MABContainer",
        "workloadType": "FileFolder",
        "errorDetails": [
          {
            "errorString": "The operation completed successfully (0x0) ",
            "recommendations": []
          }
        ],
        "entityFriendlyName": "SERVERNAME",
        "backupManagementType": "MAB",
        "operation": "Backup",
        "status": "Completed",
        "startTime": "2018-02-21T21:00:26.99Z",
        "endTime": "2018-02-21T21:25:17.082Z",
        "activityId": "ACTIVITY-ID"
      }
    }
  ]
}


DEBUG: Ignoring some of the unexpected job while conversion
DEBUG: Number of jobs fetched: 0
DEBUG: AzureQoSEvent: CommandName - Get-AzureRmRecoveryServicesBackupJob; IsSuccess - True; Duration - 00:00:07.4996067; Exception - ;
DEBUG: Finish sending metric.
DEBUG: 08:27:15 - GetAzureRmRecoveryServicesBackupJob end processing.
DEBUG: 08:27:15 - GetAzureRmRecoveryServicesBackupJob end processing.

Am I missing something or are the cmdlets not compatible with fetching information about on prem backups? The latter would feel odd since the information is obviously stored and accessible in our portal, even returned in the debug information.

Kristoffer
  • 355
  • 2
  • 14
  • What are you actually seeing in the _"HTTP RESPONSE header"_? – gvee Feb 23 '18 at 11:06
  • Also; have you checked you can see the data in the Azure Portal itself? – gvee Feb 23 '18 at 11:08
  • The HTTP response has been added. And yes, I am able to see the information in the Azure portal itself. I browse to the recovery services vault, choose the vault and then look at the backup jobs. There I can see the relevant information. – Kristoffer Feb 23 '18 at 12:26
  • from your debug info: `"backupManagementType": "MAB"`... from your code `-BackupManagementType MARS`. `/shrug` – gvee Feb 23 '18 at 12:28
  • Probably worth including the HTTP Request information for the full picture. I suspect what's happening is that the filtering is applied at the client side. – gvee Feb 23 '18 at 12:29
  • I added the full debug output. Yeah, the documentation for [Get-AzureRmRecoveryServicesBackupJob](https://learn.microsoft.com/en-us/powershell/module/azurerm.recoveryservices.backup/get-azurermrecoveryservicesbackupjob?view=azurermps-5.3.0#optional-parameters) doesn't mention MAB. I assume that's just an abbreviation of Microsoft Azure Backup, but unsure if it's significant. If it's not possible to do directly via powershell I guess I will have to look into the Azure REST API. – Kristoffer Feb 23 '18 at 13:04
  • The request itself doesn't look to filter on type. So it's safe to assume this is happening on the PS side. If you remove the `-BackupManagementType` do you get a response? – gvee Feb 23 '18 at 15:42
  • Sadly the response is the same even without `-BackupManagementType` – Kristoffer Feb 23 '18 at 15:55

0 Answers0