Open SrinivasanSelvam opened 1 month ago
@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
SUMMARY
On-demand backup of azure vm using ansible module provides 400 Bad Request
ISSUE TYPE
COMPONENT NAME
azure.azcollection.azure_rm_backupazurevm
ANSIBLE VERSION
COLLECTION VERSION
STEPS TO REPRODUCE
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