none
Python API - Restoring VM from Backup RRS feed

  • Question

  • Hi, I'm looking for examples of how to use this python api class "IaasVMRestoreRequest class"  in a python script. I want to script a restore of a vm from a backup as we have a requirement to do this and perform a number of tests against the restored vm every week. The number of vm's will increase overtime so it is a perfect candidate for automation. I relatively new to python and azure and as such I'm struggling to read the api reference as a lot of it comes without examples so I'm stumbling about in the dark. If I had access to a few examples I'm sure I could work it out from there.

    I'm kind of going in this direction 

    from azure.mgmt.recoveryservicesbackup import RecoveryServicesBackupClient
    from azure.common.client_factory import get_client_from_cli_profile
    
    def run_example():
    
        recovery_service_backup_client = get_client_from_cli_profile(RecoveryServicesBackupClient)
    
        recovery_service_backup_client.restores.trigger('')
    
    
        
    if __name__ == "__main__":
        run_example()

    but I don't even know if this is the right direction to be heading.

    If anyone can point me to some good examples of this or can post an example of how to make use of the API here I'd very much appreciate it.

    Thanks

    Tuesday, October 22, 2019 1:37 PM

Answers

All replies

  • Currently we do not have examples for this requirement. However, we are working on it and it will be made available post ignite (may be in the 3rd/4th week of Nov).
    Thursday, October 24, 2019 9:13 AM
    Moderator
  • Thanks Sadiqh, 

    Is there anyway of knowing when it becomes available (other than looking at the API docs periodically).

    Thanks Again 

    Thursday, October 24, 2019 9:28 AM
  • I shall post an update on this forum thread. You can also keep a tab on Azure updates
    Thursday, October 24, 2019 10:52 AM
    Moderator
  • Thanks Again Sadiqh I'll do that - Cheers :)
    Thursday, October 24, 2019 4:25 PM
  • Sorry for the delay in response. You can find one sample in this link - https://gist.github.com/siddharth7/d90db61f7f04603f214d4850ccf99e84

    ---------------------------------------------------------------------------------------------------------------------------
    If this answer was helpful, click “Mark as Answer” and Up-Vote.

    Wednesday, January 8, 2020 11:14 AM
    Moderator
  • Okay thanks for that the example helped me work it out. I still think there needs to be more details in the API docs though. For example information about the options for the parameters. I looked at recovery_type  and thought "What does that mean? What are the options?" There was no detail so I looked in the REST API, after a bt of a search I managed to determine IaasVMRestoreRequest was the equivalent of BackupRecovery-Restores-Trigger and that recovery_type could be AlternateLocation, Invalid, Offline, OriginalLocation, RestoresDisks, but evern here the Description field was blank. From the examples at the bottom of this page I managed to work out that I needed AlternateLocation - Phew! It's not that it is impossible to work things out but more the amount of effort it takes to go back and forth between the various pieces of documentation and the web portal to piece together what you need.

    This isn't a complaint its more of an observation and I truly appreciate the effort you all put in to maintaining updating everything.

    Cheers

    :)

    Tuesday, January 14, 2020 10:31 AM