Framework/Core/FixControl/Services/StorageFix.ps1
using namespace Microsoft.Azure.Commands.Sql.Auditing.Model using namespace Microsoft.Azure.Commands.Sql.ServerUpgrade.Model using namespace Microsoft.Azure.Commands.Sql.TransparentDataEncryption.Model using namespace Microsoft.Azure.Commands.Sql.ThreatDetection.Model Set-StrictMode -Version Latest class StorageFix: FixServicesBase { StorageFix([string] $subscriptionId, [ResourceConfig] $resourceConfig, [string] $resourceGroupName): Base($subscriptionId, $resourceConfig, $resourceGroupName) { } [MessageData[]] SetSku([PSObject] $parameters) { [MessageData[]] $detailedLogs = @(); $skuName = $parameters.SkuName; $detailedLogs += [MessageData]::new("Setting up the Sku [$skuName] for storage [$($this.ResourceName)]..."); Set-AzureRmStorageAccount -Name $this.ResourceName -ResourceGroupName $this.ResourceGroupName -SkuName $skuName $detailedLogs += [MessageData]::new("Sku setup completed for storage [$($this.ResourceName)]..."); return $detailedLogs; } [MessageData[]] EnableBlobEncryption([PSObject] $parameters) { [MessageData[]] $detailedLogs = @(); $detailedLogs += [MessageData]::new("Enabling encryption on blob service of storage [$($this.ResourceName)]..."); Set-AzureRmStorageAccount -Name $this.ResourceName -ResourceGroupName $this.ResourceGroupName -StorageEncryption -EnableEncryptionService Blob $detailedLogs += [MessageData]::new("Encryption on blob service is enabled on storage [$($this.ResourceName)]..."); return $detailedLogs; } [MessageData[]] EnableFileEncryption([PSObject] $parameters) { [MessageData[]] $detailedLogs = @(); $detailedLogs += [MessageData]::new("Enabling encryption on file service of storage [$($this.ResourceName)]..."); Set-AzureRmStorageAccount -Name $this.ResourceName -ResourceGroupName $this.ResourceGroupName -StorageEncryption -EnableEncryptionService File $detailedLogs += [MessageData]::new("Encryption on file service is enabled on storage [$($this.ResourceName)]..."); return $detailedLogs; } [MessageData[]] EnableHttpsTrafficOnly([PSObject] $parameters) { [MessageData[]] $detailedLogs = @(); $detailedLogs += [MessageData]::new("Enabling 'HTTPS traffic only' on storage [$($this.ResourceName)]..."); Set-AzureRmStorageAccount -Name $this.ResourceName -ResourceGroupName $this.ResourceGroupName -EnableHttpsTrafficOnly $true $detailedLogs += [MessageData]::new("'HTTPS traffic only' is enabled on storage [$($this.ResourceName)]..."); return $detailedLogs; } } |