I am trying to create a Sql Backup item on a RSV, however I am getting this error for this particular command: Enable-AzRecoveryServicesBackupProtection -Policy $backupPolicy -ResourceGroupName $resourceGroupName -Name $enablename

Lakshmi Meghana Mupparapu outlook 0 Reputation points
2024-07-15T12:15:07.7566667+00:00

# Get the Recovery Services Vault details
$vault = Get-AzRecoveryServicesVault -ResourceGroupName $resourceGroupName | Where-Object { $_.Name -eq $rsv }
Set-AzRecoveryServicesVaultContext -Vault $vault

# Wait for some time to ensure the vault context is set (adjust if necessary)
Start-Sleep -Seconds 20

# Get the discovered SQL instances
$containers = Get-AzRecoveryServicesBackupContainer -BackupManagementType AzureWorkload -ContainerType AzureVMAppContainer
$sqlInstance = $containers | Where-Object { $_.FriendlyName -eq $vmName }

if ($sqlInstance -eq $null) {
    Write-Output "No SQL instances found in the VM $vmName."
} else {
    # Get the backup policy
    $backupPolicy = Get-AzRecoveryServicesBackupProtectionPolicy | Where-Object { $_.Name -eq $backupPolicyName -and $_.BackupManagementType -eq "AzureWorkload" }
    #$backupPolicy.GetType().FullName
    if ($backupPolicy -eq $null) {
        Write-Output "Backup policy $backupPolicyName not found."
    } else {
        # Enable backup protection for the discovered SQL instance
        $enablename = $sqlInstance.FriendlyName
        Enable-AzRecoveryServicesBackupProtection -Policy $backupPolicy -ResourceGroupName $resourceGroupName -Name $enablename

        # Turn on Autoprotect for the discovered SQL instance
        Set-AzRecoveryServicesBackupAutoProtection -ResourceGroupName $resourceGroupName -Container $sqlInstance -EnableAutoProtection $true

        Write-Output "Backup configuration completed successfully."
    }
}

Enable-AzRecoveryServicesBackupProtection -Policy $backupPolicy -ResourceGroupName $resourceGroupName -Name $enablename
or in this manner the same error
Enable-AzRecoveryServicesBackupProtection : The current operation failed due to an internal service error "Invalid input error". Please retry the operation after some time. If the issue persists, please contact Microsoft support.

Enable-AzRecoveryServicesBackupProtection : The current operation failed due to an internal service error "Invalid input error". Please retry the operation

after some time. If the issue persists, please contact Microsoft support.

At line:1 char:1

  • Enable-AzRecoveryServicesBackupProtection -Policy $policyToUse -Resou ...
  • 
        + CategoryInfo          : InvalidOperation: (:) [Enable-AzRecove...ackupProtection], CloudException
    
        + FullyQualifiedErrorId : CloudInvalidInputError,Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.EnableAzureRmRecoveryServicesBackupProtection       
    
    
Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,286 questions
{count} votes

6 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  5. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.