Azure / azure-cli

Azure Command-Line Interface
MIT License
3.92k stars 2.88k forks source link

[Azurebackup & Restore ] What does the backuprestore.json file does here ? Unable to understand #29032

Open zameer712 opened 1 month ago

zameer712 commented 1 month ago

Describe the bug

https://learn.microsoft.com/en-us/cli/azure/dataprotection/backup-instance?view=azure-cli-latest#az-dataprotection-backup-instance-create

  1. Whats the procedure of creating an backup instance for postgresql server whats the json file here does iam unable to understand no documentation on this

az dataprotection backup-instance create -g MyResourceGroup --vault-name MyVault --backup-instance backupinstance.json

Related command

https://learn.microsoft.com/en-us/cli/azure/dataprotection/backup-instance?view=azure-cli-latest#az-dataprotection-backup-instance-create

  1. Whats the procedure of creating an backup instance for postgresql server whats the json file here does iam unable to understand no documentation on this

az dataprotection backup-instance create -g MyResourceGroup --vault-name MyVault --backup-instance backupinstance.json

Errors

https://learn.microsoft.com/en-us/cli/azure/dataprotection/backup-instance?view=azure-cli-latest#az-dataprotection-backup-instance-create

  1. Whats the procedure of creating an backup instance for postgresql server whats the json file here does iam unable to understand no documentation on this

az dataprotection backup-instance create -g MyResourceGroup --vault-name MyVault --backup-instance backupinstance.json

Issue script & Debug output

WARNING: The command requires the extension dataprotection. It will be installed first. WARNING: Default enabled including preview versions for extension installation now. Disabled in May 2024. Use '--allow-preview true' to enable it specifically if needed. Use '--allow-preview false' to install stable version only. ERROR: The command failed with an unexpected error. Here is the traceback: ERROR: 'backup_instance_name' Traceback (most recent call last): File "/opt/az/lib/python3.11/site-packages/knack/cli.py", line 233, in invoke cmd_result = self.invocation.execute(args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 664, in execute raise ex File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 731, in _run_jobs_serially results.append(self._run_job(expanded_arg, cmd_copy)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 712, in _run_job result = LongRunningOperation(cmd_copy.cli_ctx, 'Starting {}'.format(cmd_copy.name))(result) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/az/lib/python3.11/site-packages/azure/cli/core/commands/init.py", line 1039, in call result = poller.result() ^^^^^^^^^^^^^^^ File "/opt/az/lib/python3.11/site-packages/azure/cli/core/aaz/_poller.py", line 108, in result self.wait(timeout) File "/opt/az/lib/python3.11/site-packages/azure/core/tracing/decorator.py", line 76, in wrapper_use_tracer return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/opt/az/lib/python3.11/site-packages/azure/cli/core/aaz/_poller.py", line 130, in wait raise self._exception File "/opt/az/lib/python3.11/site-packages/azure/cli/core/aaz/_poller.py", line 83, in _start for polling_method in self._polling_generator: File "/opt/az/azcliextensions/dataprotection/azext_dataprotection/manual/aaz_operations/backup_instance.py", line 92, in _execute_operations self.pre_operations() File "/opt/az/azcliextensions/dataprotection/azext_dataprotection/manual/aaz_operations/backup_instance.py", line 98, in pre_operations self.ctx.args.backup_instance_name = self.ctx.args.backup_instance['backup_instance_name']


  File "/opt/az/lib/python3.11/site-packages/azure/cli/core/aaz/_field_value.py", line 2[75](https://github.com/Maersk-Global/Athena_Backup_Restore/actions/runs/9256797258/job/25463567477#step:5:76), in __getitem__
    return self._data[key]
           ~~~~~~~~~~^^^^^
KeyError: 'backup_instance_name'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
New-AzDataProtectionBackupInstance: /home/runner/work/_temp/30816bea-dac4-4294-9ea4-1921fbffadc7.ps1:9
Line |
   9 |  New-AzDataProtectionBackupInstance
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot process command because of one or more missing mandatory
     | parameters: ResourceGroupName VaultName BackupInstance.
Error: Error: The process '/usr/

### Expected behavior

    - name: Azure PowerShell script
      uses: azure/powershell@v1
      with:
        inlineScript: |
            Uninstall-Module -Name Az -AllVersions
            Get-module -Name Az -ListAvailable
            Install-Module -Name Az -Repository PSGallery -AllowClobber -RequiredVersion 11.6.0 -Force
            Uninstall-Module -Name Az.DataProtection -RequiredVersion 2.2.0 -Force
            Install-Module -Name Az.DataProtection -Repository PSGallery -AllowClobber -RequiredVersion 2.4.0 -Force
            # Check if the module is installed
            az dataprotection backup-instance create -g ${{ github.event.inputs.resource_group_name }} --vault-name ${{ github.event.inputs.backupvault_name }} --backup-instance weucathpsqlf02_backupinstance.json
            New-AzDataProtectionBackupInstance 
        azPSVersion: "11.6.0"

Script being used for running backup isntance

### Environment Summary

/usr/share:/home/runner/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules
Initializing Az Module Complete
Running Az PowerShell Script
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command /home/runner/work/_temp/30816bea-dac4-4294-9ea4-1921fbffadc7.ps1
Uninstall-Package: No match was found for the specified search criteria and module names 'Az'.
    Directory: /usr/share/az_11.6.0
ModuleType Version    PreRelease Name                                PSEdition
---------- -------    ---------- ----                                ---------
Script     11.6.0                Az                                  Core,Desk
    Directory: /usr/share/az_11.3.1
ModuleType Version    PreRelease Name                                PSEdition
---------- -------    ---------- ----                                ---------
Script     11.3.1                Az                                  Core,Desk
    Directory: /usr/share/az_11.6.0
ModuleType Version    PreRelease Name                                PSEdition
---------- -------    ---------- ----                                ---------
Script     11.6.0                Az                                  Core,Desk

### Additional context

/usr/share:/home/runner/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules
Initializing Az Module Complete
Running Az PowerShell Script
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command /home/runner/work/_temp/30816bea-dac4-4294-9ea4-1921fbffadc7.ps1
Uninstall-Package: No match was found for the specified search criteria and module names 'Az'.
    Directory: /usr/share/az_11.6.0
ModuleType Version    PreRelease Name                                PSEdition
---------- -------    ---------- ----                                ---------
Script     11.6.0                Az                                  Core,Desk
    Directory: /usr/share/az_11.3.1
ModuleType Version    PreRelease Name                                PSEdition
---------- -------    ---------- ----                                ---------
Script     11.3.1                Az                                  Core,Desk
    Directory: /usr/share/az_11.6.0
ModuleType Version    PreRelease Name                                PSEdition
---------- -------    ---------- ----                                ---------
Script     11.6.0                Az                                  Core,Desk
yonzhan commented 1 month ago

Thank you for opening this issue, we will look into it.