Skip to content

Add new cmdlet, update commands.Sql and tests for 'List database operation' and 'List/Cancel elastic pool operation' #5762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 30, 2018

Conversation

payiAzure
Copy link
Contributor

@payiAzure payiAzure commented Mar 16, 2018

Description

The Changes in the PR is made from local .NET SDK binaries. Will update this PR after the corresponding .NET SDK is published.

The changes included in the PR:

  1. Add new cmdlet: Stop-AureRmSqlElasticPoolActivity -ResourceGroupName -ServerName -ElasticPoolName -OperationId

  2. Update the AzureSqlDatabaseActivityModel and AzureSqlElasticPoolActivityModel. When user try to get the database/elasticPool operations, the returned information of the operation will also include the new fields:
    estimated completion time of the operation;
    detail operation description;
    mark to indicate if the operation can be cancelled.

  3. Add test for the new added cmdlet.

Checklist

jaredmoo
jaredmoo previously approved these changes Mar 16, 2018

return resp.Select((activity) =>
var resp = from activity in activityResp
join operation in operationResp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -189,6 +239,27 @@ internal IList<AzureSqlDatabaseActivityModel> ListElasticPoolDatabaseActivity(st
}).ToList();
}

/// <summary>
/// Cancel teh elastic pool activity
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo : "teh"

/// No user input to apply to model
/// </summary>
/// <param name="model">Model retrieved from service</param>
/// <returns>The model that wa passed in</returns>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo : "wa"

@@ -0,0 +1 @@
---external help file: Microsoft.Azure.Commands.Sql.dll-Help.xmlModule Name: AzureRM.Sqlonline version:schema: 2.0.0---# Stop-AzureRmSqlElasticPoolActivity## SYNOPSIS{{Fill in the Synopsis}}## SYNTAX```Stop-AzureRmSqlElasticPoolActivity [-ServerName] <String> [-ElasticPoolName] <String> [-OperationId <Guid>] [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]```## DESCRIPTIONThe **Stop-AzureRmSqlElasticPoolActivity** cmdlet cancels the asynchronous updates operation on the elastic pool.## EXAMPLES### Example 1: Cancel the asynchronous updates operation on the elastic pool```PS C:\> Stop-AzureRmSqlElasticPoolActivity -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -ElasticPoolName "ElasticPool01" -OperationId af97005d-9243-4f8a-844e-402d1cc855f5```OperationId : af97005d-9243-4f8a-844e-402d1cc855f5ServerName : Server01DatabaseName : ElasticPool01State : CANCELLEDOperation : UpdateLogicalElasticPoolErrorCode :ErrorMessage :ErrorSeverity :StartTime : 10/15/2017 02:49:42 PMEndTime : 10/15/2017 02:49:43 PMPercentComplete : ```This command cancels the asynchronous updates operation on the elastic pool.## PARAMETERS### -DefaultProfileThe credentials, account, tenant, and subscription used for communication with Azure.```yamlType: IAzureContextContainerParameter Sets: (All)Aliases: AzureRmContext, AzureCredentialRequired: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False```### -ElasticPoolNameThe name of the Azure SQL Elastic Pool.```yamlType: StringParameter Sets: (All)Aliases:Required: TruePosition: 2Default value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False```### -OperationIdThe ID of the operation to retrieve.```yamlType: GuidParameter Sets: (All)Aliases:Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False```### -ResourceGroupNameThe name of the resource group.```yamlType: StringParameter Sets: (All)Aliases:Required: TruePosition: 0Default value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False```### -ServerNameThe name of the Azure SQL Server the Elastic Pool is in.```yamlType: StringParameter Sets: (All)Aliases:Required: TruePosition: 1Default value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False```### -ConfirmPrompts you for confirmation before running the cmdlet.```yamlType: SwitchParameterParameter Sets: (All)Aliases: cfRequired: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False```### -WhatIfShows what would happen if the cmdlet runs.The cmdlet is not run.```yamlType: SwitchParameterParameter Sets: (All)Aliases: wiRequired: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False```### CommonParametersThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).## INPUTS### System.StringSystem.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]## OUTPUTS### System.Object## NOTES## RELATED LINKS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synopsis is empty : "{{Fill in the Synopsis}}"

Copy link
Member

@cormacpayne cormacpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@payiAzure a few comments to take a look at. Also, please make sure to update the Sql change log with a snippet that reflects the changes being made in this PR?

@@ -0,0 +1 @@
---external help file: Microsoft.Azure.Commands.Sql.dll-Help.xmlModule Name: AzureRM.Sqlonline version:schema: 2.0.0---# Stop-AzureRmSqlElasticPoolActivity## SYNOPSISCancels the asynchronous updates operation on the elastic pool.## SYNTAX```Stop-AzureRmSqlElasticPoolActivity [-ServerName] <String> [-ElasticPoolName] <String> [-OperationId <Guid>] [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]```## DESCRIPTIONThe **Stop-AzureRmSqlElasticPoolActivity** cmdlet cancels the asynchronous updates operation on the elastic pool.## EXAMPLES### Example 1: Cancel the asynchronous updates operation on the elastic pool```PS C:\> Stop-AzureRmSqlElasticPoolActivity -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -ElasticPoolName "ElasticPool01" -OperationId af97005d-9243-4f8a-844e-402d1cc855f5```OperationId : af97005d-9243-4f8a-844e-402d1cc855f5ServerName : Server01DatabaseName : ElasticPool01State : CANCELLEDOperation : UpdateLogicalElasticPoolErrorCode :ErrorMessage :ErrorSeverity :StartTime : 10/15/2017 02:49:42 PMEndTime : 10/15/2017 02:49:43 PMPercentComplete : ```This command cancels the asynchronous updates operation on the elastic pool.## PARAMETERS### -DefaultProfileThe credentials, account, tenant, and subscription used for communication with Azure.```yamlType: IAzureContextContainerParameter Sets: (All)Aliases: AzureRmContext, AzureCredentialRequired: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False```### -ElasticPoolNameThe name of the Azure SQL Elastic Pool.```yamlType: StringParameter Sets: (All)Aliases:Required: TruePosition: 2Default value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False```### -OperationIdThe ID of the operation to retrieve.```yamlType: GuidParameter Sets: (All)Aliases:Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False```### -ResourceGroupNameThe name of the resource group.```yamlType: StringParameter Sets: (All)Aliases:Required: TruePosition: 0Default value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False```### -ServerNameThe name of the Azure SQL Server the Elastic Pool is in.```yamlType: StringParameter Sets: (All)Aliases:Required: TruePosition: 1Default value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False```### -ConfirmPrompts you for confirmation before running the cmdlet.```yamlType: SwitchParameterParameter Sets: (All)Aliases: cfRequired: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False```### -WhatIfShows what would happen if the cmdlet runs.The cmdlet is not run.```yamlType: SwitchParameterParameter Sets: (All)Aliases: wiRequired: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False```### CommonParametersThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).## INPUTS### System.StringSystem.Nullable`1[[System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]## OUTPUTS### System.Object## NOTES## RELATED LINKS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@payiAzure there's something wrong with how this file is encoded -- it's all on one line and there are a ton of red ^M characters in this file. Would you mind ensuring that this is using UTF-8 encoding?

Using GitHub to edit this file, it appears there are a few encoding characters on the first line of the file that you can remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cormacpayne updated this md file, should have correct format now.

namespace Microsoft.Azure.Commands.Sql.ElasticPool.Cmdlet
{
[Cmdlet(VerbsLifecycle.Stop, "AzureRmSqlElasticPoolActivity", SupportsShouldProcess = true)]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@payiAzure nit: remove this blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cormacpayne removed in the new commit.


namespace Microsoft.Azure.Commands.Sql.ElasticPool.Cmdlet
{
[Cmdlet(VerbsLifecycle.Stop, "AzureRmSqlElasticPoolActivity", SupportsShouldProcess = true)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@payiAzure please add an OutputType to this cmdlet -- if this cmdlet does not return any output, then you should implement the PassThru parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cormacpayne I'm not clear about what is the PassThru parameter and how to implement it? can you please point me to any example?
Since I just follow one existing command to implement this similar one. "StopAzureSqlDatabaseActivity.cs"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cormacpayne .Add OutputType and implement the PassThru parameter.

function Test-ListAndCancelElasticPoolOperation
{
# Setup
$location = "southeastasia";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@payiAzure please avoid hard-coding locations in tests -- this potentially makes it difficult for other users to re-record this test who might not have access to the resources in the provided location. We recommend using the Get-Location function in our test common code to get a location that works for the user re-recording the test.


try
{
$activityCancel = Stop-AzureRmSqlElasticPoolActivity -ResourceGroupName $ep.ResourceGroupName -ServerName $ep.ServerName -ElasticPoolName $ep.ElasticPoolName -OperationId $epactivityId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@payiAzure just to be sure, should this command always error out? If not, then we should add some asserts over the returned $activityCancel object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, in the test, it will always error out since the previous update operation makes the pool in an state that is not available in cancel.

@cormacpayne cormacpayne assigned payiAzure and unassigned markcowl Mar 19, 2018
@payiAzure payiAzure changed the title [DO NOT MERGE, create from local .Net SDK build] Add new cmdlet, update commands.Sql and tests for 'List database operation' and 'Lst/Cancel elastic pool operation' [DO NOT MERGE, create from local .Net SDK build] Add new cmdlet, update commands.Sql and tests for 'List database operation' and 'List/Cancel elastic pool operation' Mar 19, 2018
@payiAzure payiAzure force-pushed the azure-powershell-br1 branch from 78b2b26 to cfbbe6e Compare March 19, 2018 22:37
@payiAzure payiAzure changed the title [DO NOT MERGE, create from local .Net SDK build] Add new cmdlet, update commands.Sql and tests for 'List database operation' and 'List/Cancel elastic pool operation' Add new cmdlet, update commands.Sql and tests for 'List database operation' and 'List/Cancel elastic pool operation' Mar 20, 2018
jaredmoo
jaredmoo previously approved these changes Mar 20, 2018
@@ -189,7 +189,8 @@ CmdletsToExport = 'Get-AzureRmSqlDatabaseTransparentDataEncryption',
'Remove-AzureRmSqlServerVirtualNetworkRule',
'Stop-AzureRmSqlDatabaseActivity', 'Get-AzureRmSqlServerDnsAlias',
'Remove-AzureRmSqlServerDnsAlias', 'New-AzureRmSqlServerDnsAlias',
'Set-AzureRmSqlServerDnsAlias'
'Set-AzureRmSqlServerDnsAlias',
'Stop-AzureRmSqlElasticPoolActivity'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix indentation here

Communicator.CancelOperation(resourceGroupName, serverName, elasticPoolName, operationId.Value);

// After Cancel event is fired, state will be in 'CancelInProgress' for a while but should expect to finish in a minute
return GetElasticPoolActivity(resourceGroupName, serverName, elasticPoolName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

# Stop-AzureRmSqlElasticPoolActivity

## SYNOPSIS
Cancels the asynchronous updates operation on the elastic pool.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cancels an asynchronous update operation on an elastic pool.

```

## DESCRIPTION
The **Stop-AzureRmSqlElasticPoolActivity** cmdlet cancels the asynchronous updates operation on the elastic pool.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... cancels an asynchronous update operation on an elastic pool.

PercentComplete :
```

This command cancels the asynchronous updates operation on the elastic pool.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jaredmoo , comments addressed in the new commit.


### Example 1: Cancel the asynchronous updates operation on the elastic pool
```
PS C:\> Stop-AzureRmSqlElasticPoolActivity -ResourceGroupName "ResourceGroup01" -ServerName "Server01" -ElasticPoolName "ElasticPool01" -OperationId af97005d-9243-4f8a-844e-402d1cc855f5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quotes not needed

@payiAzure
Copy link
Contributor Author

@cormacpayne Can you please review this again? I have addressed the comments. I add the help url in the help file, but not sure why the build check still fail here. I can build from local.

@cormacpayne
Copy link
Member

@payiAzure would you mind taking a look at the merge conflicts? Also, the build is failing because the packages.config files in the Sql projects have not been updated with the new version of Microsoft.Azure.Management.Sql. Please make sure to update these files when pulling in the latest changes from the preview branch.

@payiAzure
Copy link
Contributor Author

@cormacpayne Fix the merge conflict issue and the build failure issues. Could you please take a review? Thank you!

@cormacpayne
Copy link
Member

cormacpayne commented Mar 29, 2018

@maddieclayton
Copy link
Contributor

@markcowl
Copy link
Member

@maddieclayton maddieclayton merged commit 9a25b3a into Azure:preview Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants