Skip to content

Commit bfb6ba9

Browse files
committed
Merge branch 'preview' of github.com:/azure/azure-powershell into msiagain
2 parents e3d5696 + 72b3ca0 commit bfb6ba9

File tree

22 files changed

+7751
-24843
lines changed

22 files changed

+7751
-24843
lines changed

src/ResourceManager/Compute/Commands.Compute/Extension/AzureDiskEncryption/Scripts/AzureDiskEncryptionPreRequisiteSetup.ps1

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,13 @@ $ErrorActionPreference = "Stop"
4343
########################################################################################################################
4444
# Section1: Log-in to Azure and select appropriate subscription.
4545
########################################################################################################################
46-
4746

4847
Select-AzureRmSubscription -SubscriptionId $subscriptionId;
4948

50-
5149
########################################################################################################################
5250
# Section2: Create AAD app . Fill in $aadClientSecret variable if AAD app was already created
5351
########################################################################################################################
5452

55-
5653
# Check if AAD app with $aadAppName was already created
5754
$SvcPrincipals = (Get-AzureRmADServicePrincipal -SearchString $aadAppName);
5855
if(-not $SvcPrincipals)
@@ -187,7 +184,36 @@ $ErrorActionPreference = "Stop"
187184
Read-Host;
188185

189186
########################################################################################################################
190-
# For each VM you want to encrypt, run the below cmdlet
191-
# $vmName = 'Name of VM to encrypt';
192-
# Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $resourceGroupName -VMName $vmName -AadClientID $aadClientID -AadClientSecret $aadClientSecret -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $keyVaultResourceId -VolumeType All
187+
# To encrypt one VM in given resource group of the logged in subscritpion, assign $vmName and uncomment below section
188+
########################################################################################################################
189+
#$vmName = "Your VM Name";
190+
#$allVMs = Get-AzureRmVm -ResourceGroupName $resourceGroupName -Name $vmName;
191+
192+
########################################################################################################################
193+
# To encrypt all the VMs in the given resource group of the logged in subscription uncomment below section
193194
########################################################################################################################
195+
#$allVMs = Get-AzureRmVm -ResourceGroupName $resourceGroupName;
196+
197+
########################################################################################################################
198+
# To encrypt all the VMs in the all the resource groups of the logged in subscription, uncomment below section
199+
########################################################################################################################
200+
#$allVMs = Get-AzureRmVm;
201+
202+
########################################################################################################################
203+
# Loop through the selected list of VMs and enable encryption
204+
########################################################################################################################
205+
206+
foreach($vm in $allVMs)
207+
{
208+
Write-Host "Encrypting VM: $($vm.Name) in ResourceGroup: $($vm.ResourceGroupName) " -foregroundcolor Green;
209+
if(-not $kek)
210+
{
211+
Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $vm.ResourceGroupName -VMName $vm.Name -AadClientID $aadClientID -AadClientSecret $aadClientSecret -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $keyVaultResourceId -VolumeType 'All';
212+
}
213+
else
214+
{
215+
Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $vm.ResourceGroupName -VMName $vm.Name -AadClientID $aadClientID -AadClientSecret $aadClientSecret -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $keyVaultResourceId -KeyEncryptionKeyUrl $keyEncryptionKeyUrl -KeyEncryptionKeyVaultId $keyVaultResourceId -VolumeType 'All';
216+
}
217+
# Show encryption status of the VM
218+
Get-AzureRmVmDiskEncryptionStatus -ResourceGroupName $vm.ResourceGroupName -VMName $vm.Name;
219+
}

src/ResourceManager/Sql/AzureRM.Sql.psd1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ CmdletsToExport = 'Get-AzureRmSqlDatabaseTransparentDataEncryption',
140140
'Get-AzureRmSqlServerBackupLongTermRetentionVault',
141141
'Restore-AzureRmSqlDatabase',
142142
'Set-AzureRmSqlServerBackupLongTermRetentionVault',
143-
'Get-AzureRmSqlDatabaseRestorePoints',
143+
'Get-AzureRmSqlDatabaseRestorePoints',
144144
'Get-AzureRmSqlDatabaseAuditingPolicy',
145145
'Get-AzureRmSqlServerAuditingPolicy',
146146
'Get-AzureRmSqlDatabaseAuditing', 'Get-AzureRmSqlServerAuditing',
@@ -189,8 +189,11 @@ CmdletsToExport = 'Get-AzureRmSqlDatabaseTransparentDataEncryption',
189189
'Stop-AzureRmSqlDatabaseActivity', 'Get-AzureRmSqlServerDnsAlias',
190190
'Remove-AzureRmSqlServerDnsAlias', 'New-AzureRmSqlServerDnsAlias',
191191
'Set-AzureRmSqlServerDnsAlias',
192+
'New-AzureRmSqlDatabaseRestorePoint',
193+
'Remove-AzureRmSqlDatabaseRestorePoint',
192194
'Stop-AzureRmSqlElasticPoolActivity'
193195

196+
194197
# Variables to export from this module
195198
# VariablesToExport = @()
196199

src/ResourceManager/Sql/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
* Added ResourceGroup Completer to -ResourceGroup parameters allowing tab completion through resource groups in current subscription
4040
* Added -AsJob parameter to long running cmdlets
4141
* Obsoleted -DatabaseName parameter from Get-AzureRmSqlServiceObjective
42+
* Adding New-AzureRmSqlDatabaseRestorePoint, Remove-AzureRmSqlDatabaseRestorePoint and output model of Get-AzureRmSqlDatabaseRestorePoints will have one more field
4243

4344
## Version 4.1.1
4445
* Added ability to rename database using Set-AzureRmSqlDatabase

src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,12 @@
564564
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestListDatabaseRestorePoints.json">
565565
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
566566
</None>
567+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestNewDatabaseRestorePoint.json">
568+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
569+
</None>
570+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestRemoveDatabaseRestorePoint.json">
571+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
572+
</None>
567573
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupTests\TestLongTermRetentionV2.json">
568574
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
569575
</None>

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseBackupTests.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void TestLongTermRetentionV2Backup()
103103
{
104104
RunPowerShellTest("Test-LongTermRetentionV2Backup");
105105
}
106-
[Fact]
106+
[Fact(Skip = "This is not recordable test")]
107107
[Trait(Category.AcceptanceType, Category.CheckIn)]
108108
public void TestLongTermRetentionV2()
109109
{
@@ -125,5 +125,27 @@ public void TestDatabaseGeoBackupPolicy()
125125
RunPowerShellTest("Test-DatabaseGeoBackupPolicy");
126126
}
127127
}
128+
[Fact]
129+
[Trait(Category.AcceptanceType, Category.CheckIn)]
130+
public void TestNewDatabaseRestorePoint()
131+
{
132+
// TODO Rewrite SQL backup tests to be recordable
133+
// TODO https://github.com/Azure/azure-powershell/issues/4155
134+
if (TestMockSupport.RunningMocked)
135+
{
136+
RunPowerShellTest("Test-NewDatabaseRestorePoint");
137+
}
138+
}
139+
[Fact]
140+
[Trait(Category.AcceptanceType, Category.CheckIn)]
141+
public void TestRemoveDatabaseRestorePoint()
142+
{
143+
// TODO Rewrite SQL backup tests to be recordable
144+
// TODO https://github.com/Azure/azure-powershell/issues/4155
145+
if (TestMockSupport.RunningMocked)
146+
{
147+
RunPowerShellTest("Test-RemoveDatabaseRestorePoint");
148+
}
149+
}
128150
}
129151
}

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseBackupTests.ps1

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,83 @@ function Test-DatabaseGeoBackupPolicy
276276
Set-AzureRmSqlDatabaseGeoBackupPolicy -ServerName $server.ServerName -ResourceGroupName $rg.ResourceGroupName -DatabaseName $db.DatabaseName -State Disabled
277277
$result = Get-AzureRmSqlDatabaseGeoBackupPolicy -ServerName $server.ServerName -ResourceGroupName $rg.ResourceGroupName -DatabaseName $db.DatabaseName
278278
Assert-True { $result.State -eq "Disabled" }
279+
}
280+
281+
function Test-NewDatabaseRestorePoint
282+
{
283+
# Setup
284+
$location = Get-Location "Microsoft.Sql" "servers" "West US 2"
285+
$serverVersion = "12.0";
286+
$label = "label01";
287+
$rg = Create-ResourceGroupForTest
288+
289+
try
290+
{
291+
$server = Create-ServerForTest $rg $location
292+
293+
# Create data warehouse database with all parameters.
294+
$databaseName = Get-DatabaseName
295+
$dwdb = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
296+
-Edition DataWarehouse -RequestedServiceObjectiveName DW100
297+
298+
New-AzureRmSqlDatabaseRestorePoint -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $dwdb.DatabaseName -RestorePointLabel $label
299+
300+
# Get restore points from data warehouse database.
301+
$restorePoints = Get-AzureRmSqlDatabaseRestorePoints -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $dwdb.DatabaseName
302+
303+
# We just created a restore point
304+
Assert-AreEqual $restorePoints.Count 1
305+
$restorePoint = $restorePoints[0]
306+
Assert-AreEqual $restorePoint.RestorePointType DISCRETE
307+
Assert-Null $restorePoint.EarliestRestoreDate
308+
Assert-AreEqual $restorePoint.RestorePointCreationDate.Kind Utc
309+
Assert-AreEqual $restorePoint.RestorePointLabel $label
310+
}
311+
finally
312+
{
313+
Remove-ResourceGroupForTest $rg
314+
}
315+
}
316+
317+
function Test-RemoveDatabaseRestorePoint
318+
{
319+
# Setup
320+
$location = Get-Location "Microsoft.Sql" "servers" "West central US"
321+
$serverVersion = "12.0";
322+
$label = "label01";
323+
$rg = Create-ResourceGroupForTest
324+
325+
try
326+
{
327+
$server = Create-ServerForTest $rg $location
328+
329+
# Create data warehouse database with all parameters.
330+
$databaseName = Get-DatabaseName
331+
$dwdb = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
332+
-Edition DataWarehouse -RequestedServiceObjectiveName DW100
333+
334+
New-AzureRmSqlDatabaseRestorePoint -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $dwdb.DatabaseName -RestorePointLabel $label
335+
336+
# Get restore points from data warehouse database.
337+
$restorePoints = Get-AzureRmSqlDatabaseRestorePoints -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $dwdb.DatabaseName
338+
339+
# We just created a restore point
340+
Assert-AreEqual $restorePoints.Count 1
341+
$restorePoint = $restorePoints[0]
342+
Assert-AreEqual $restorePoint.RestorePointType DISCRETE
343+
Assert-Null $restorePoint.EarliestRestoreDate
344+
Assert-AreEqual $restorePoint.RestorePointCreationDate.Kind Utc
345+
346+
Remove-AzureRmSqlDatabaseRestorePoint -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $dwdb.DatabaseName -RestorePointCreationDate $restorePoint.RestorePointCreationDate
347+
348+
# Get restore points from data warehouse database.
349+
$restorePoints = Get-AzureRmSqlDatabaseRestorePoints -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $dwdb.DatabaseName
350+
351+
# We just created a restore point
352+
Assert-AreEqual $restorePoints.Count 0
353+
}
354+
finally
355+
{
356+
Remove-ResourceGroupForTest $rg
357+
}
279358
}

src/ResourceManager/Sql/Commands.Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseBackupStretchTests/TestStretchDatabaseListRestorePoints.json

Lines changed: 699 additions & 15342 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)