Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On-demand backup of azure vm using ansible module provides 400 Bad Request #1698

Open
SrinivasanSelvam opened this issue Sep 2, 2024 · 2 comments
Labels
medium_priority Medium priority not a bug Not a bug question Further information is requested

Comments

@SrinivasanSelvam
Copy link

SrinivasanSelvam commented Sep 2, 2024

SUMMARY

On-demand backup of azure vm using ansible module provides 400 Bad Request

ISSUE TYPE
  • Bug Report
COMPONENT NAME

azure.azcollection.azure_rm_backupazurevm

ANSIBLE VERSION
ansible [core 2.14.3]
COLLECTION VERSION
azure-cli                         2.56.0 *

core                              2.56.0 *
telemetry                          1.1.0

Extensions:
dataprotection                     0.6.0

Dependencies:
msal                            1.24.0b2
azure-mgmt-resource             23.1.0b2

Python location '/opt/azure-cli/bin/python3'
Extensions directory '/home/deployment/.azure/cliextensions'

Python (Linux) 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
STEPS TO REPRODUCE
Below are the snippets in playbook yaml  values taken from inventory file 
value of state is backup

- name: Trigger an on-demand backup for {{ vm_name }}
  azure.azcollection.azure_rm_backupazurevm:
     resource_group: '{{ resource_group }}'
     recovery_vault_name: '{{ vault_name }}'
     resource_id: '{{ vm_id }}'
     backup_policy_id: '{{ policy_id }}'
     recovery_point_expiry_time: '{{ backup_expiry_time }}'
     state: '{{ state }}'
 register: backup_creation
EXPECTED RESULTS

As per ansible documentation of the azure_rm_backupazurevm moduel, It should trigger ondemand backup of azure vm if state provided as backup

ACTUAL RESULTS
Wednesday 28 August 2024  12:12:01 +0000 (0:00:00.026)       0:00:05.047 ******                                                                              
[WARNING]: Azure API profile latest does not define an entry for GenericRestClient                                                                           
fatal: [<vm_name>]: FAILED! => changed=false 
  msg: 'Error while taking on-demand backup: (<RequestsTransportResponse: 400 Bad Request, Content-Type: application/json>, 400)' 

@Fred-sun
Copy link
Collaborator

@SrinivasanSelvam From the error code you returned, it appears that you have a problem in submitting the request parameters. Can you help provide the following information? Because I followed the script below to create, update, stop, and delete azure VM backups without any problems.

First: detailed error information
Second: You back up the status of the virtual machine, the version of aze.azcollection you installed.

- name: Fix resource prefix
  ansible.builtin.set_fact:
    recovery_vault_name: 'MyRecoveryVault'
    resource_id: "/subscriptions/xxx/resourceGroups/test_group/providers/Microsoft.Compute/virtualMachines/test"
    backup_policy_id: "/subscriptions/xxx/resourceGroups/v-xisuRG/providers/Microsoft.RecoveryServices/vaults/MyRecoveryVault/backupPolicies/EnhancedPolicy"

- name: Create Azure Recovery Service vault
  azure_rm_recoveryservicesvault:
    resource_group: "{{ resource_group }}"
    name: "{{ recovery_vault_name }}"
    location:  westus2
    state: "present"
  register: output

- name: Enabling/Updating protection for the Azure VM
  azure_rm_backupazurevm:
    resource_group: "{{ resource_group }}"
    recovery_vault_name: "{{ recovery_vault_name }}"
    resource_id: "{{ resource_id }}"
    backup_policy_id: "{{ backup_policy_id }}"
    state: "create"
  register: output

- name: Trigger an on-demand backup for a protected Azure VM
  azure_rm_backupazurevm:
    resource_group: "{{ resource_group }}"
    recovery_vault_name: "{{ recovery_vault_name }}"
    resource_id: "{{ resource_id }}"
    backup_policy_id: "{{ backup_policy_id }}"
    recovery_point_expiry_time: "2025-02-03T05:00:00Z"
    state: "backup"
  register: output

- name: Stop protection but retain existing data
  azure_rm_backupazurevm:
    resource_group: "{{ resource_group }}"
    recovery_vault_name: "{{ recovery_vault_name }}"
    resource_id: "{{ resource_id }}"
    backup_policy_id: "{{ backup_policy_id }}"
    state: "stop"
  register: output

- name: Stop protection and delete data
  azure_rm_backupazurevm:
    resource_group: "{{ resource_group }}"
    recovery_vault_name: "{{ recovery_vault_name }}"
    resource_id: "{{ resource_id }}"
    backup_policy_id: "{{ backup_policy_id }}"
    state: "delete"
  register: output

@Fred-sun Fred-sun added question Further information is requested medium_priority Medium priority work in In trying to solve, or in working with contributors labels Oct 17, 2024
@Fred-sun Fred-sun added not a bug Not a bug and removed work in In trying to solve, or in working with contributors labels Oct 30, 2024
@Fred-sun
Copy link
Collaborator

kindly ping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
medium_priority Medium priority not a bug Not a bug question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants