Skip to content

Commit d3e986e

Browse files
authored
Merge pull request #4755 from jiawang003/preview
cmdlets to get DB operation status and cancel pending operation
2 parents fd7e39c + 7e23e2c commit d3e986e

20 files changed

+10299
-23
lines changed

src/ResourceManager/Sql/AzureRM.Sql.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ CmdletsToExport = 'Get-AzureRmSqlDatabaseTransparentDataEncryption',
181181
'New-AzureRmSqlServerVirtualNetworkRule',
182182
'Set-AzureRmSqlServerVirtualNetworkRule',
183183
'Get-AzureRmSqlServerVirtualNetworkRule',
184-
'Remove-AzureRmSqlServerVirtualNetworkRule'
184+
'Remove-AzureRmSqlServerVirtualNetworkRule',
185+
'Stop-AzureRmSqlDatabaseActivity'
185186

186187
# Variables to export from this module
187188
# VariablesToExport = @()

src/ResourceManager/Sql/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Adding support for list and cancel the asynchronous updateslo operation on the database
22+
- update existing cmdlet Get-AzureRmSqlDatabaseActivity to return DB updateslo operation status.
23+
- add new cmdlet Stop-AzureRmSqlDatabaseActivity for cancel the asynchronous updateslo operation on the database.
2124

2225
## Version 3.4.1
2326

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@
8181
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.14.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
8282
</Reference>
8383
<Reference Include="Microsoft.Azure.Management.Sql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
84-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.1.6.0-preview\lib\net452\Microsoft.Azure.Management.Sql.dll</HintPath>
84+
<SpecificVersion>False</SpecificVersion>
85+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Sql.1.7.0-preview\lib\net452\Microsoft.Azure.Management.Sql.dll</HintPath>
8586
<Private>True</Private>
8687
</Reference>
8788
<Reference Include="Microsoft.Azure.Management.Storage">
@@ -118,11 +119,13 @@
118119
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.28.3\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
119120
</Reference>
120121
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
121-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.8\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
122+
<SpecificVersion>False</SpecificVersion>
123+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.10\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
122124
<Private>True</Private>
123125
</Reference>
124126
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
125-
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.7\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
127+
<SpecificVersion>False</SpecificVersion>
128+
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.10\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
126129
<Private>True</Private>
127130
</Reference>
128131
<Reference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -640,6 +643,9 @@
640643
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudStretchTests\TestStretchDatabaseUpdate.json">
641644
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
642645
</None>
646+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCancelOperation.json">
647+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
648+
</None>
643649
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreate.json">
644650
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
645651
</None>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,12 @@ public void TestDatabaseRemove()
7272
{
7373
RunPowerShellTest("Test-RemoveDatabase");
7474
}
75+
76+
[Fact]
77+
[Trait(Category.AcceptanceType, Category.CheckIn)]
78+
public void TestDatabaseCancelOperation()
79+
{
80+
RunPowerShellTest("Test-CancelDatabaseOperation");
81+
}
7582
}
7683
}

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,62 @@ function Test-RemoveDatabaseInternal ($location = "westcentralus")
324324
{
325325
Remove-ResourceGroupForTest $rg
326326
}
327+
}
328+
329+
330+
<#
331+
.SYNOPSIS
332+
Tests listing and cancelling a database operation
333+
#>
334+
function Test-CancelDatabaseOperation
335+
{
336+
Test-CancelDatabaseOperationInternal "North Europe"
337+
}
338+
339+
<#
340+
.SYNOPSIS
341+
Tests listing and cancelling a database operation
342+
#>
343+
function Test-CancelDatabaseOperationInternal ($location = "westcentralus")
344+
{
345+
# Setup
346+
$rg = Create-ResourceGroupForTest
347+
$server = Create-ServerForTest $rg $location
348+
349+
$databaseName = Get-DatabaseName
350+
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
351+
-Edition Standard -MaxSizeBytes 250GB -RequestedServiceObjectiveName S0
352+
Assert-AreEqual $db.DatabaseName $databaseName
353+
354+
# Database will be Standard s0 with maxsize: 268435456000 (250GB)
355+
356+
try
357+
{
358+
# Alter all properties
359+
$db1 = Set-AzureRmSqlDatabase -ResourceGroupName $db.ResourceGroupName -ServerName $db.ServerName -DatabaseName $db.DatabaseName `
360+
-Edition Standard -RequestedServiceObjectiveName S1
361+
Assert-AreEqual $db1.DatabaseName $db.DatabaseName
362+
Assert-AreEqual $db1.Edition Standard
363+
Assert-AreEqual $db1.CurrentServiceObjectiveName S1
364+
365+
# list and cancel a database operation
366+
$dbactivity = Get-AzureRmSqlDatabaseActivity -ResourceGroupName $db.ResourceGroupName -ServerName $db.ServerName -DatabaseName $db.DatabaseName
367+
Assert-AreEqual $dbactivity.DatabaseName $db.DatabaseName
368+
Assert-AreEqual $dbactivity.Operation "UpdateLogicalDatabase"
369+
370+
$dbactivityId = $dbactivity.OperationId
371+
try
372+
{
373+
$dbactivityCancel = Stop-AzureRmSqlDatabaseActivity -ResourceGroupName $db.ResourceGroupName -ServerName $db.ServerName -DatabaseName $db.DatabaseName -OperationId $dbactivityId
374+
}
375+
Catch
376+
{
377+
$ErrorMessage = $_.Exception.Message
378+
Assert-AreEqual True $ErrorMessage.Contains("Cannot cancel database management operation '" + $dbactivityId + "' in the current state")
379+
}
380+
}
381+
finally
382+
{
383+
Remove-ResourceGroupForTest $rg
384+
}
327385
}

0 commit comments

Comments
 (0)