public override void ExecuteCmdlet() { ExecutionBlock(() => { try { ResourceIdentifier resourceIdentifier = new ResourceIdentifier(VaultId); string vaultName = resourceIdentifier.ResourceName; string resourceGroupName = resourceIdentifier.ResourceGroupName; BackupResourceVaultConfigResource currentConfig = ServiceClientAdapter.GetVaultProperty(vaultName, resourceGroupName); BackupResourceVaultConfigResource param = new BackupResourceVaultConfigResource(); param.Properties = new BackupResourceVaultConfig(); param.Properties.SoftDeleteFeatureState = SoftDeleteFeatureState + "d"; param.Properties.EnhancedSecurityState = currentConfig.Properties.EnhancedSecurityState; BackupResourceVaultConfigResource result = ServiceClientAdapter.SetVaultProperty(vaultName, resourceGroupName, param); WriteObject(result.Properties); } catch (Exception exception) { WriteExceptionError(exception); } }, ShouldProcess(VaultId, VerbsCommon.Set)); }
public override void ExecuteCmdlet() { try { ResourceIdentifier resourceIdentifier = new ResourceIdentifier(VaultId); string vaultName = resourceIdentifier.ResourceName; string resourceGroupName = resourceIdentifier.ResourceGroupName; BackupResourceVaultConfigResource result = ServiceClientAdapter.GetVaultProperty(vaultName, resourceGroupName); WriteObject(result.Properties); } catch (Exception exception) { WriteExceptionError(exception); } }
public override void ExecuteCmdlet() { ExecutionBlock(() => { try { ResourceIdentifier resourceIdentifier = new ResourceIdentifier(VaultId); string vaultName = resourceIdentifier.ResourceName; string resourceGroupName = resourceIdentifier.ResourceGroupName; if (SoftDeleteFeatureState != null) { BackupResourceVaultConfigResource currentConfig = ServiceClientAdapter.GetVaultProperty(vaultName, resourceGroupName); BackupResourceVaultConfigResource param = new BackupResourceVaultConfigResource(); param.Properties = new BackupResourceVaultConfig(); param.Properties.SoftDeleteFeatureState = SoftDeleteFeatureState + "d"; param.Properties.EnhancedSecurityState = currentConfig.Properties.EnhancedSecurityState; BackupResourceVaultConfigResource result = ServiceClientAdapter.SetVaultProperty(vaultName, resourceGroupName, param); WriteObject(result.Properties); } else if (EncryptionKeyId != null) { BackupResourceEncryptionConfigResource vaultEncryptionSettings = new BackupResourceEncryptionConfigResource(); vaultEncryptionSettings.Properties = new BackupResourceEncryptionConfig(); vaultEncryptionSettings.Properties.EncryptionAtRestType = "CustomerManaged"; vaultEncryptionSettings.Properties.KeyUri = EncryptionKeyId; if (InfrastructureEncryption.IsPresent) { vaultEncryptionSettings.Properties.InfrastructureEncryptionState = "Enabled"; } vaultEncryptionSettings.Properties.SubscriptionId = KeyVaultSubscriptionId; vaultEncryptionSettings.Properties.LastUpdateStatus = null; var response = ServiceClientAdapter.UpdateVaultEncryptionConfig(resourceGroupName, vaultName, vaultEncryptionSettings); } } catch (Exception exception) { WriteExceptionError(exception); } }, ShouldProcess(VaultId, VerbsCommon.Set)); }
public override void ExecuteCmdlet() { try { ResourceIdentifier resourceIdentifier = new ResourceIdentifier(VaultId); string vaultName = resourceIdentifier.ResourceName; string resourceGroupName = resourceIdentifier.ResourceGroupName; BackupResourceEncryptionConfigExtendedResource vaultEncryptionSetting = ServiceClientAdapter.GetVaultEncryptionConfig(resourceGroupName, vaultName); BackupResourceVaultConfigResource vaultConfigResource = ServiceClientAdapter.GetVaultProperty(vaultName, resourceGroupName); VaultProperty vaultProperty = new VaultProperty(vaultConfigResource.Properties, vaultEncryptionSetting); WriteObject(vaultProperty); } catch (Exception exception) { WriteExceptionError(exception); } }
public override void ExecuteCmdlet() { ExecutionBlock(() => { try { ResourceIdentifier resourceIdentifier = new ResourceIdentifier(VaultId); string vaultName = resourceIdentifier.ResourceName; string resourceGroupName = resourceIdentifier.ResourceGroupName; if (SoftDeleteFeatureState != null || DisableHybridBackupSecurityFeature != null) { BackupResourceVaultConfigResource currentConfig = ServiceClientAdapter.GetVaultProperty(vaultName, resourceGroupName); BackupResourceVaultConfigResource param = new BackupResourceVaultConfigResource(); param.Properties = new BackupResourceVaultConfig(); param.Properties.SoftDeleteFeatureState = (SoftDeleteFeatureState != null) ? SoftDeleteFeatureState + "d" : currentConfig.Properties.SoftDeleteFeatureState; param.Properties.EnhancedSecurityState = (DisableHybridBackupSecurityFeature != null) ? (((bool)DisableHybridBackupSecurityFeature) ? "Disabled" : "Enabled") : currentConfig.Properties.EnhancedSecurityState; bool isMUAProtected = checkMUAForSoftDelete(currentConfig, param); BackupResourceVaultConfigResource result = ServiceClientAdapter.SetVaultProperty(vaultName, resourceGroupName, param, Token, isMUAProtected); WriteObject(result.Properties); } else if (EncryptionKeyId != null) { BackupResourceEncryptionConfigResource vaultEncryptionSettings = new BackupResourceEncryptionConfigResource(); vaultEncryptionSettings.Properties = new BackupResourceEncryptionConfig(); PatchVault patchVault = new PatchVault(); patchVault.Properties = new VaultProperties(); VaultPropertiesEncryption vaultEncryption = new VaultPropertiesEncryption(); vaultEncryption.KeyVaultProperties = new CmkKeyVaultProperties(); vaultEncryption.KekIdentity = new CmkKekIdentity(); vaultEncryption.KeyVaultProperties.KeyUri = EncryptionKeyId; if (InfrastructureEncryption.IsPresent) { vaultEncryption.InfrastructureEncryption = "Enabled"; } vaultEncryption.KekIdentity.UseSystemAssignedIdentity = UseSystemAssignedIdentity; if (!UseSystemAssignedIdentity && (UserAssignedIdentity == null || UserAssignedIdentity == "")) { throw new ArgumentException(Resources.IdentityIdRequiredForCMK); } else if (!UseSystemAssignedIdentity) { vaultEncryption.KekIdentity.UserAssignedIdentity = UserAssignedIdentity; } patchVault.Properties.Encryption = vaultEncryption; ServiceClientAdapter.UpdateRSVault(resourceGroupName, vaultName, patchVault); } } catch (Exception exception) { WriteExceptionError(exception); } }, ShouldProcess(VaultId, VerbsCommon.Set)); }