Used to create/remove snapshots of the disk page blobs of the specified virtual machines.
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            AzureVMBackupExtensionUtil azureBackupExtensionUtil = new AzureVMBackupExtensionUtil();

            AzureVMBackupConfig vmConfig = new AzureVMBackupConfig();
            vmConfig.ResourceGroupName = ResourceGroupName;
            vmConfig.VMName = VMName;
            vmConfig.ExtensionName = Name;
            vmConfig.VirtualMachineExtensionType = VirtualMachineExtensionType;

            azureBackupExtensionUtil.CreateSnapshotForDisks(vmConfig,Tag, this);
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            AzureVMBackupExtensionUtil azureBackupExtensionUtil = new AzureVMBackupExtensionUtil();

            AzureVMBackupConfig vmConfig = new AzureVMBackupConfig();
            vmConfig.ResourceGroupName = ResourceGroupName;
            vmConfig.VMName = this.VMName;
            vmConfig.ExtensionName = this.Name;
            vmConfig.VirtualMachineExtensionType = VirtualMachineExtensionType;

            azureBackupExtensionUtil.CreateSnapshotForDisks(vmConfig,Tag, this);
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var virtualMachineResponse = this.ComputeClient.ComputeManagementClient.VirtualMachines.GetWithInstanceView(this.ResourceGroupName, VMName);
            var currentOSType = virtualMachineResponse.Body.StorageProfile.OsDisk.OsType;

            if (OperatingSystemTypes.Linux.Equals(currentOSType))
            {
                AzureVMBackupExtensionUtil util = new AzureVMBackupExtensionUtil();
                AzureVMBackupConfig vmConfig = new AzureVMBackupConfig();
                vmConfig.ResourceGroupName = ResourceGroupName;
                vmConfig.VMName = VMName;
                vmConfig.VirtualMachineExtensionType = VirtualMachineExtensionType;
                util.RemoveSnapshot(vmConfig, Tag, this);
            }
            else
            {
                ThrowTerminatingError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "The VM should be a Linux VM")),
                                                      "InvalidArgument",
                                                      ErrorCategory.InvalidArgument,
                                                      null));
            }
        }
Exemplo n.º 4
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            VirtualMachineGetResponse virtualMachineResponse = this.ComputeClient.ComputeManagementClient.VirtualMachines.GetWithInstanceView(this.ResourceGroupName, VMName);
            string currentOSType = virtualMachineResponse.VirtualMachine.StorageProfile.OSDisk.OperatingSystemType;

            if (string.Equals(currentOSType, "Linux", StringComparison.InvariantCultureIgnoreCase))
            {
                AzureVMBackupExtensionUtil util     = new AzureVMBackupExtensionUtil();
                AzureVMBackupConfig        vmConfig = new AzureVMBackupConfig();
                vmConfig.ResourceGroupName           = ResourceGroupName;
                vmConfig.VMName                      = VMName;
                vmConfig.VirtualMachineExtensionType = VirtualMachineExtensionType;
                util.RemoveSnapshot(vmConfig, Tag, this);
            }
            else
            {
                ThrowTerminatingError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "The VM should be a Linux VM")),
                                                      "InvalidArgument",
                                                      ErrorCategory.InvalidArgument,
                                                      null));
            }
        }
Exemplo n.º 5
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var virtualMachineResponse = this.ComputeClient.ComputeManagementClient.VirtualMachines.GetWithInstanceView(this.ResourceGroupName, VMName);
            var currentOSType          = virtualMachineResponse.Body.StorageProfile.OsDisk.OsType;

            if (OperatingSystemTypes.Linux.Equals(currentOSType))
            {
                AzureVMBackupExtensionUtil util     = new AzureVMBackupExtensionUtil();
                AzureVMBackupConfig        vmConfig = new AzureVMBackupConfig();
                vmConfig.ResourceGroupName           = ResourceGroupName;
                vmConfig.VMName                      = VMName;
                vmConfig.VirtualMachineExtensionType = VirtualMachineExtensionType;
                util.RemoveSnapshot(vmConfig, Tag, this);
            }
            else
            {
                ThrowTerminatingError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "The VM should be a Linux VM")),
                                                      "InvalidArgument",
                                                      ErrorCategory.InvalidArgument,
                                                      null));
            }
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            VirtualMachineGetResponse virtualMachineResponse = this.ComputeClient.ComputeManagementClient.VirtualMachines.GetWithInstanceView(this.ResourceGroupName, VMName);
            string currentOSType = virtualMachineResponse.VirtualMachine.StorageProfile.OSDisk.OperatingSystemType;

            if (string.Equals(currentOSType, "Linux", StringComparison.InvariantCultureIgnoreCase))
            {
                AzureVMBackupExtensionUtil util = new AzureVMBackupExtensionUtil();
                AzureVMBackupConfig vmConfig = new AzureVMBackupConfig();
                vmConfig.ResourceGroupName = ResourceGroupName;
                vmConfig.VMName = VMName;
                vmConfig.VirtualMachineExtensionType = VirtualMachineExtensionType;
                util.RemoveSnapshot(vmConfig, Tag, this);
            }
            else
            {
                ThrowTerminatingError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "The VM should be a Linux VM")),
                                                      "InvalidArgument",
                                                      ErrorCategory.InvalidArgument,
                                                      null));
            }
        }
     private void CreateVMBackupForLinx()
     {
         try
         {
             AzureVMBackupExtensionUtil azureBackupExtensionUtil = new AzureVMBackupExtensionUtil();
             AzureVMBackupConfig vmConfig = new AzureVMBackupConfig();
             vmConfig.ResourceGroupName = ResourceGroupName;
             vmConfig.VMName = VMName;
             vmConfig.VirtualMachineExtensionType = VirtualMachineExtensionType;
             string tag = string.Format("{0}{1}", "AzureEnc", Guid.NewGuid().ToString());
             // this would create shapshot only for Linux box. and we should wait for the snapshot found.
             azureBackupExtensionUtil.CreateSnapshotForDisks(vmConfig, tag, this);
             WriteWarning(string.Format("one snapshot for disks are created with tag,{0}, you can use {1}-{2} to remove it.", tag, VerbsCommon.Remove,
 ProfileNouns.AzureVMBackup));
         }
         catch (AzureVMBackupException e)
         {
             ThrowTerminatingError(new ErrorRecord(new ApplicationException(string.Format(CultureInfo.CurrentUICulture, e.ToString())),
                                                   "InvalidResult",
                                                   ErrorCategory.InvalidResult,
                                                   null));
         }
     }