/// <summary>
        /// Updates the encryption extension in the virtual machine using provided configuration.
        /// If extension is not installed then this method return null else the updated vm.
        /// </summary>
        /// <param name="encryptConfig">The volume encryption configuration.</param>
        /// <return>Tasks that emits updated virtual machine.</return>
        ///GENMHASH:99CCEB2CE75C64E72E8D4CB8CFDA73B5:B2EAD454D0D489C6F6AC659E4EB949F0
        private async Task <Microsoft.Azure.Management.Compute.Fluent.IVirtualMachine> UpdateEncryptionExtensionAsync(EnableDisableEncryptConfig encryptConfig, CancellationToken cancellationToken = default(CancellationToken))
        {
            IVirtualMachineExtension extension = await GetEncryptionExtensionInstalledInVMAsync(cancellationToken);

            if (extension == null)
            {
                return(await Task.FromResult <IVirtualMachine>(null));
            }
            return(await virtualMachine.Update()
                   .UpdateExtension(extension.Name)
                   .WithPublicSettings(encryptConfig.ExtensionPublicSettings())
                   .WithProtectedSettings(encryptConfig.ExtensionProtectedSettings())
                   .Parent()
                   .ApplyAsync(cancellationToken));
        }
        /// <summary>
        /// Prepare encryption extension using provided configuration and install it in the virtual machine.
        /// </summary>
        /// <param name="encryptConfig">The volume encryption configuration.</param>
        /// <return>An observable that emits updated virtual machine.</return>
        ///GENMHASH:90F5E95CF3EB9C10D9E436E206241DB8:709FA1AD6AFC4D8E0EEEB4F58D788AFA
        private async Task <Microsoft.Azure.Management.Compute.Fluent.IVirtualMachine> InstallEncryptionExtensionAsync(EnableDisableEncryptConfig encryptConfig, CancellationToken cancellationToken = default(CancellationToken))
        {
            string extensionName = EncryptionExtensionType();

            return(await virtualMachine.Update()
                   .DefineNewExtension(extensionName)
                   .WithPublisher(encryptionExtensionPublisher)
                   .WithType(EncryptionExtensionType())
                   .WithVersion(EncryptionExtensionVersion())
                   .WithPublicSettings(encryptConfig.ExtensionPublicSettings())
                   .WithProtectedSettings(encryptConfig.ExtensionProtectedSettings())
                   .WithMinorVersionAutoUpgrade()
                   .Attach()
                   .ApplyAsync(cancellationToken));
        }
        /// <summary>
        /// Updates the virtual machine's OS Disk model with the encryption specific details.
        /// </summary>
        /// <param name="encryptConfig">The configuration specific to disabling the encryption.</param>
        /// <return>An observable that emits updated virtual machine.</return>
        ///GENMHASH:9E912268A5CDF429573A7112EC718690:63BF821D222D03E59BCD43264C3339D8
        private async Task <Microsoft.Azure.Management.Compute.Fluent.IVirtualMachine> UpdateVMStorageProfileAsync(EnableDisableEncryptConfig encryptConfig, CancellationToken cancellationToken = default(CancellationToken))
        {
            DiskEncryptionSettings diskEncryptionSettings = encryptConfig.StorageProfileEncryptionSettings();

            return(await virtualMachine.Update()
                   .WithOSDiskEncryptionSettings(diskEncryptionSettings)
                   .ApplyAsync(cancellationToken));
        }