How to create a azure vm backup via python sdk . Steps needed please with example
- Operating System: Linux
- Python Version: 3.6
Describe the bug Not able to create a backup of azure vm via python sdk,. Need clear cut example if you have one.. Thank you Can you please give some documentation with example how to do create given vm backup via python sdk please
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @pvrk.
you can refer this doc: https://docs.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2020_06_01.operations.virtualmachinesoperations?view=azure-python
seems method Capture may help you.
you can refer this doc: https://docs.microsoft.com/en-us/python/api/azure-mgmt-compute/azure.mgmt.compute.v2020_06_01.operations.virtualmachinesoperations?view=azure-python
seems method Capture may help you.
Hi thanks for reply,
I am looking for creation of backup via vault recovery services available on azure portal, as of now we are doing loggin in via portal, i wanted to perform this activity via python sdk.. can we have some usecase example please
which vault recovery services you used?I can check whether we have correspondin python sdk?
@sambitratha: Do we have some examples we can share out of our Azure CLI implementation?
@sambitratha: Do we have some examples we can share out of our Azure CLI implementation?
Thank you shall wait for it :).
@sambitratha: Do we have some examples we can share out of our Azure CLI implementation?
@pvrk Hi, can i get some example please. it will be really help us
@pvrk @sambitratha can we have some example please...
@onenessboy : @sambitratha is working on this. Since this is the first time we have had this request, it is taking some time for us. Apologize for the inconvenience caused.
@onenessboy : @sambitratha is working on this. Since this is the first time we have had this request, it is taking some time for us. Apologize for the inconvenience caused.
Thanks @pvrk for update. Sorry for the push. I know there are powershell to handle, but in our case we are moving ahead with pythonic way automation(due to integration plans) hence the ask. I am sorry to say, we dont have any full fledged python examples anywhere on internet (still googling for hours with out a valid example) :( hence the followup. we will be glad if we can get some workable sample. thank you. I hope i would see more python based sdk examples to automate our azure activities..
@onenessboy : Thanks for understanding. Once we have this sample, we will plan to officially publish samples for these scenarios as well so that it will be useful to everyone else.
@onenessboy : Thanks for understanding. Once we have this sample, we will plan to officially publish samples for these scenarios as well so that it will be useful to everyone else.
@pvrk thanks for update, meanwhile waiting for that, i raised another similar request but intention to find backup status of a azure vm via python sdk, though i figured out something but unless i give vault name, vault recovery resource group name and backup policy name then i am only getting status (i followed GET REST API for this in pythn program), but whole idea is to get backup status simply by providing hostname of azure , by hostname, it should find bacakupvaultname, and its vault resource group and backupplocy name dynamically substitute in GET API then give us result) . I have opened another issue with #12977 few days ago, if our existing solution which you were trying to have cover this aspect as well Please have a look at this issue details once. In our internal discussion, requestor told that i am able to see backup status in just 3 clicks, login to portal, click on backup, see the status. why cant you do these 3 steps in python (its very simple for them) but for me unless i have a concrete example difficult to execute :)
@onenessboy : This API is exactly for that purpose. You only need to provide the ARM ID of the VM, and the result will give you the vault name, backup item name and the policy name.
@onenessboy : This API is exactly for that purpose. You only need to provide the ARM ID of the VM, and the result will give you the vault name, backup item name and the policy name.
@pvrk thanks for that API, but that does not work in our case, we wanted output as per this API https://docs.microsoft.com/en-us/rest/api/backup/backupprotecteditems/list which is we are exactly looking for these to work I need to know backupvaultname, vault resource group name and backuppolicy name to fetch status where I supply filter condition as "$filter=backupManagementType eq 'AzureIaasVM' and itemType eq 'VM' and policyName eq '{backup_policy_name}' so now the issue is i want to know this information only by passing hostname not all other vault related parameters, i have to find it programatically. I wrote some python program based on this api, but it wont work unless i pass vault name,vault resourgroupname and backup policy name before hand, which is not possible all the time, only information we get is hostname (from perspective of automation)
@onenessboy Please find the attached sample script to configure backup for VM . Let us know if it helps.
@onenessboy Please find the attached sample script to configure backup for VM . Let us know if it helps.
Thank you @mepand , shall check, meanwhile, our use case is trigerring a backup is vaultbased, hope this covers that one...anyway letme try @pvrk Karthik, special thanks to you for following it up for sample
@onenessboy Please find the attached sample script to configure backup for VM . Let us know if it helps.
Hi @mepand
My intial understand of script is that we need to pass vaultname,vault resource group .vmname,vm rg as parameters . (correct if i am wrong in this understanding) If my understanding is correct, this may not work, our requriement is to just pass on VM name, then it script should get its vault name, vault resourgrame, backupoloyc, then do a adhoc backup (in simple terms, how we login into portal --> click on vm --> go to backup upsection --> click on backup, we need to do the same via python sdk).. (my requriement is specifically to kicoff an adhoc backup of existing vm which is already configured on vault)
@onenessboy : Unfortunately, we translated this requirement differently "How to create a Azure VM backup" -> We translated as "how to configure backup for an unprotected VM". We supplied the script for that. Now, we have clarified requirement: "my requirement is specifically to kicoff an adhoc backup of existing vm which is already configured on vault and with only VM name". This is a completely different requirement have to go with the mixed API approach (API to get vault details using VM name -> Then trigger a backup for that backup item). I will try to see if we can do that but this will take few days because of other priorities.
@onenessboy : Unfortunately, we translated this requirement differently "How to create a Azure VM backup" -> We translated as "how to configure backup for an unprotected VM". We supplied the script for that. Now, we have clarified requirement: "my requirement is specifically to kicoff an adhoc backup of existing vm which is already configured on vault and with only VM name". This is a completely different requirement have to go with the mixed API approach (API to get vault details using VM name -> Then trigger a backup for that backup item). I will try to see if we can do that but this will take few days because of other priorities.
@pvrk thanks for update. but yeah, I shall wait for solution ..no other choice than waiting :). Might be i could have asked question in detailed manner when I created this ticket :) hmm. Anyway thanks for help
@onenessboy : For starters, the script will accept ARM ID of the VM. Hope that's fine.