Skip to content

Set-AzRecoveryServicesBackupProperty does not function as designed.  #25704

Open
@cdiskan

Description

@cdiskan

Description

The Set-AzRecoveryServicesBackupProperty cmdlet does not appear to function as designed. It does not produce errors, but instead does absolutely nothing.

In my test scenario a newly created vault exists. no backups exist in this vault yet, and the vault can be toggled between LRS and GRS in the portal, as well as enable or disable cross-region restore.

Attempting to set either the cross-region restore, or the backup storage redundancy (As documented here: https://learn.microsoft.com/en-us/powershell/module/az.recoveryservices/set-azrecoveryservicesbackupproperty?view=azps-12.0.0 ) results in no change to the recovery services vault.

Example to demonstrate bug
`Write-host "Getting vault"
$vault = Get-AzRecoveryServicesVault -ResourceGroupName $AttributeList.ResourceGroup -Name $AttributeList.RecoveryServicesVaultName

Write-Host "Initial Vault Properties"
get-AzRecoveryServicesBackupProperty -Vault $vault

Write-host "Setting vault redundancy"
Set-AzRecoveryServicesBackupProperty -Vault $vault -BackupStorageRedundancy LocallyRedundant -Verbose

Write-host "Vault Properties after redundancy change"
get-AzRecoveryServicesBackupProperty -Vault $vault

Write-host "Setting vault cross-region"
Set-AzRecoveryServicesBackupProperty -Vault $vault -EnableCrossRegionRestore -Verbose

Write-host "Vault Properties after cross-region change"
get-AzRecoveryServicesBackupProperty -Vault $vault
`

image
image

I did find this somewhat cryptic entry in the debug logs that seems to indicate that you cannot use this API for the desired changes. However, I cannot find any mention of this error online, or any indication of why the creation of this vault (Via Azure Powershell, not Azure CLI) would trigger this incompatibility.

Body:
{
  "error": {
    "code": "BMSUserErrorRedundancySettingsUseVaultApi",
    "message": "Redundancy settings for this vault cannot be modified using this API. Since the Vault API was previously used to update the redundancy set
tings for this vault, you must again use the Vault API to make any further changes to this property."
  }
}

DebugOutput.txt

Issue script & Debug output

Script and debug in attached .txt file as it was too long for the github upload (Max length > 65536 chars)

Environment data

(Note, this output is from a PSv5 session, but the same issue can be replicated in PSv7.)

$PSVersionTable

Name                           Value                                                                                                                     
----                           -----                                                                                                                     
PSVersion                      5.1.22621.3880                                                                                                            
PSEdition                      Desktop                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                   
BuildVersion                   10.0.22621.3880                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                           
WSManStackVersion              3.0                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                       
SerializationVersion           1.1.0.1

Module versions

PS C:\Users\USERNAME> get-module az*

ModuleType Version    Name                                ExportedCommands                                                                               
---------- -------    ----                                ----------------                                                                               
Script     3.0.2      Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault...}                       
Script     7.0.0      Az.RecoveryServices                 {Add-AzRecoveryServicesAsrReplicationProtectedItemDisk, Backup-AzRecoveryServicesBackupItem,...

Error output

Nothing relevant (Easier than sanitizing the results of my fat-fingered connect-azaccounts)

Activity

added
bugThis issue requires a change to an existing behavior in the product in order to be resolved.
needs-triageThis is a new issue that needs to be triaged to the appropriate team.
on Jul 30, 2024
hiaga

hiaga commented on Aug 2, 2024

@hiaga
Member

Hi @cdiskan, Thanks for bringing this to our notice. This has been already tracked by us and we are working on adding support for this in the Update-AzRecoveryServicesVault command. Will keep you posted with the timelines.

Meanwhile, you can use the Invoke-RestMethod to call the PATCH vault API directly or using powershell.

hiaga

hiaga commented on Aug 2, 2024

@hiaga
Member

Please set these values correctly

$subscriptionId = "vault-subscription-Id"
$resourceGroupName = "vault_rg"
$vaultName = "vault-name"

Set-AzContext -SubscriptionId $subscriptionId
$accesstoken = Get-AzAccessToken
$token = $accesstoken.Token
$authHeader = @{
'Content-Type'='application/json'
'Authorization'='Bearer ' + $token
}

update below URL to call actual API, this is just an example

$restUri = 'https://management.azure.com/subscriptions/' + $subscriptionId + '/resourceGroups/' + $resourceGroupName + '/providers/Microsoft.RecoveryServices/vaults/' + $vaultname + '/yourRESTAPI?api-version=2024-04-01'

prepare request body

$requestBody = "{
'key1': [
'value1',
'value2'
],
'key2': 'value3'
}"

Invoke the API with apropriate REST method - POST/PATCH/GET/DELETE. more details about the API here

$response = Invoke-RestMethod -Uri $restUri -Headers $authHeader -Method PATCH -Body $requestBody -ResponseHeadersVariable responseHeader

$response.properties| fl
$responseHeader.'x-ms-client-request-id'

cdiskan

cdiskan commented on Aug 3, 2024

@cdiskan
Author

Awesome, thank you!

Any time estimate on when the fix will be released into the standard AZ powershell module?

Alex-wdy

Alex-wdy commented on Aug 30, 2024

@Alex-wdy
Contributor
hiaga

hiaga commented on Oct 4, 2024

@hiaga
Member

It will take couple of months, will update this thread once the fix is released

kamfaima

kamfaima commented on May 21, 2025

@kamfaima

Perhaps related to this issue is that I'm getting the same error when attempting to create a RSV and setting the same options as the OP using Bicep. Would this mean that it's not so much the method (pwsh or Bicep) but perhaps ARM itself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Recovery Services BackupService AttentionThis issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reported

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @isra-fel@cdiskan@hiaga@kamfaima@Alex-wdy

        Issue actions

          Set-AzRecoveryServicesBackupProperty does not function as designed. · Issue #25704 · Azure/azure-powershell