/// <summary>
        /// Enables encryption.
        /// </summary>
        /// <param name="encryptionSettings">The settings to be used for encryption extension.</param>
        /// <param name="">The Windows or Linux encryption settings.</param>
        /// <return>An observable that emits the encryption status.</return>
        ///GENMHASH:FB7DBA27A41CC76685F21AB0A9729C82:D88D73A86520940C4EA57E9CEEA1516F
        internal async Task <IDiskVolumeEncryptionMonitor> EnableEncryptionAsync <T>(VirtualMachineEncryptionConfiguration <T> encryptionSettings,
                                                                                     CancellationToken cancellationToken = default(CancellationToken)) where T : VirtualMachineEncryptionConfiguration <T>
        {
            var encryptConfig = new EnableEncryptConfig <T>(encryptionSettings);
            // Update the encryption extension if already installed
            //
            IVirtualMachine virtualMachine = await UpdateEncryptionExtensionAsync(encryptConfig, cancellationToken);

            if (virtualMachine == null)
            {
                // If encryption extension is not installed then install it
                //
                virtualMachine = await InstallEncryptionExtensionAsync(encryptConfig, cancellationToken);
            }
            // Retrieve the encryption key URL after extension install or update
            //
            string keyVaultSecretUrl = await RetrieveEncryptionExtensionStatusStringAsync(ERROR_EXPECTED_KEY_VAULT_URL_NOT_FOUND, cancellationToken);

            // Update the VM's OS Disk (in storage profile) with the encryption metadata
            //
            virtualMachine = await UpdateVMStorageProfileAsync(encryptConfig, keyVaultSecretUrl, cancellationToken);

            // Gets the encryption status
            //
            return(await GetDiskVolumeEncryptDecryptStatusAsync(virtualMachine, cancellationToken));
        }
示例#2
0
 /// <summary>
 /// Creates an instance of type representing settings to enable encryption.
 /// </summary>
 /// <param name="config">The user provided encryption configuration.</param>
 /// <return>Enable settings.</return>
 internal static Enable <T> CreateEnable <T>(VirtualMachineEncryptionConfiguration <T> config)
     where T : VirtualMachineEncryptionConfiguration <T>
 {
     return(new EncryptionSettings.Enable <T>(config));
 }
示例#3
0
 internal Enable(VirtualMachineEncryptionConfiguration <T> config)
 {
     this.config = config;
 }
 ///GENMHASH:A4680AAD3C732AD8C23180D4695F0002:2D5ABDE502752AC4098DD0B501F665E5
 public EnableEncryptConfig(VirtualMachineEncryptionConfiguration <T> settings)
 {
     this.settings = settings;
 }