Skip to content

[ADF] Adding Update-AzureRmDataFactoryV2 and Stop-AzureRmDataFactoryV2PipelineRun #5045

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 15 commits into from
Dec 6, 2017

Conversation

hvermis
Copy link
Contributor

@hvermis hvermis commented Nov 29, 2017

Description


Adding 2 new cmdlets for ADF V2: Update-AzureRmDataFactoryV2 and Stop-AzureRmDataFactoryV2PipelineRun with tests. Also added aliases for Set- cmdlets to also be discoverable with New- verb.
This checklist is used to make sure that common guidelines for a pull request are followed. You can find a more complete discussion of PowerShell cmdlet best practices here.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
  • The pull request does not introduce breaking changes (unless a major version change occurs in the assembly and module).

Testing Guidelines

  • Pull request includes test coverage for the included changes.
  • PowerShell scripts used in tests should do any necessary setup as part of the test or suite setup, and should not use hard-coded values for locations or existing resources.

Cmdlet Signature Guidelines

  • New cmdlets that make changes or have side effects should implement ShouldProcess and have SupportShouldProcess=true specified in the cmdlet attribute. You can find more information on ShouldProcess here.
  • Cmdlet specifies OutputType attribute if any output is produced - if the cmdlet produces no output, it should implement a PassThru parameter.

Cmdlet Parameter Guidelines

  • Parameter types should not expose types from the management library - complex parameter types should be defined in the module.
  • Complex parameter types are discouraged - a parameter type should be simple types as often as possible. If complex types are used, they should be shallow and easily creatable from a constructor or another cmdlet.
  • Cmdlet parameter sets should be mutually exclusive - each parameter set must have at least one mandatory parameter not in other parameter sets.

@hvermis hvermis requested a review from cormacpayne November 29, 2017 04:05
@hvermis
Copy link
Contributor Author

hvermis commented Nov 29, 2017

@maddieclayton This PR also contains Cancel pipeline run, please review.
CC: @milantomic6

Copy link
Contributor

@maddieclayton maddieclayton left a comment

Choose a reason for hiding this comment

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

Added comments for Stop-AzureRmDataFactoryV2PipelineRun.

@@ -31,5 +31,11 @@ public void TestRunV2()
RunPowerShellTest("Test-Run");
}

[Fact]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test for a successful cancellation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified the run test to include it

@@ -75,6 +75,7 @@ FunctionsToExport = @()
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport =
'Set-AzureRmDataFactoryV2',
'Update-AzureRmDataFactoryV2',
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the change log with information about these two new cmdlets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

public class StopAzureDataFactoryPipelineRunCommand : DataFactoryContextBaseCmdlet
{
[Parameter(ParameterSetName = ParameterSetNames.ByInputObject, Position = 0, Mandatory = true, ValueFromPipeline = true,
HelpMessage = Constants.HelpPipelineRunId)]
Copy link
Contributor

Choose a reason for hiding this comment

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

This help message is confusing for the user - make a new entry in Constants for this InputObject

public override void ExecuteCmdlet()
{
ByFactoryObject(DataFactory);
if (ParameterSetName.Equals(ParameterSetNames.ByInputObject, StringComparison.OrdinalIgnoreCase))
Copy link
Contributor

Choose a reason for hiding this comment

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

You might also move ByInputObject from DataFactoryContextActionBaseCmdlet to DataFactoryContextBaseCmdlet so you can use it here. Alternatively, is there a reason you aren't inheriting from DataFactoryContextActionBaseCmdlet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not this one because it is also assigning the pipeline run id in case by input object.
ActionBase also has ResourceId parameter which can't be added to this cmdlet as the pipelineRun is not an azure resource.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense, got it.


### Example 1
```
PS C:\> Stop-AzureRmDataFactoryV2PipelineRun -ResourceGroupName "ADF" -DataFactoryName "UncycloADF" -PipelineRunId b9730a13-aa12-4926-a8b3-8e3a974ab0bd
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add an example for each parameter set? Also, make sure this isn't a real DataFactory/PipelineRunId.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our other cmdlets also only have 1, at most 2 examples - at some point we will have vendors to write more detailed descriptions in Powersehll docs and add more examples.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, as long as there are definite plans in the future for improving documentation.

true
```

This command stops the pipelin run with id b9730a13-aa12-4926-a8b3-8e3a974ab0bd in the factory UncycloADF.
Copy link
Contributor

Choose a reason for hiding this comment

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

*pipeline

@hvermis hvermis assigned maddieclayton and unassigned hvermis Nov 30, 2017
Copy link
Contributor

@maddieclayton maddieclayton left a comment

Choose a reason for hiding this comment

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

One small comment, and then the Stop-AzureRmDataFactoryV2PipelineRun cmdlet looks good to me. Waiting on review from @cormacpayne for the other cmdlet.

@@ -43,7 +43,8 @@ function Test-Run
Set-AzureRmDataFactoryV2Pipeline -ResourceGroupName $rgname -Name $pipelineName -DataFactoryName $dfname -File ".\Resources\pipeline.json" -Force

$Run = Invoke-AzureRmDataFactoryV2Pipeline -ResourceGroupName $rgname -PipelineName $pipelineName -DataFactoryName $dfname -Parameter @{"OutputBlobName"="test";}

Assert-True { Stop-AzureRmDataFactoryV2PipelineRun -ResourceGroupName $rgname -PipelineRunId $Run -DataFactoryName $dfname -Force -PassThru}

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a bigger problem here that none of the Get cmdlets are not being thoroughly tested, but this is good enough for the Stop cmdlet.

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, I saw that too. The author probably wanted to just make sure it doesn't throw an exception. I will follow up with them.

@@ -19,5 +19,8 @@
-->

## Current Release
* Added 2 new cmdlets: Update-AzureRmDataFactoryV2 and Stop-AzureRmDataFactoryV2PipelineRun

## 2017.09.25 - Version 0.3.0 (Previous Release)
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to add this new header, it will be done automatically in the next release. Just keep everything under the current release header.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@maddieclayton maddieclayton dismissed their stale review November 30, 2017 21:20

issues addressed

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.

@hvermis a couple of comments to take a look at

@@ -19,5 +19,5 @@
-->

## Current Release
* Azure DataFactory Powershell cmdlets for ADF V2 Private Preview
Copy link
Member

Choose a reason for hiding this comment

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

@hvermis looks like the change log didn't get updated from the previous release - this should look like the following:

## Current Release
* Added two new cmdlets: Update-AzureRmDataFactoryV2 and Stop-AzureRmDataFactoryV2PipelineRun

## Version 0.1.0
* Azure DataFactory PowerShell cmdlets for ADF V2 Private Preview

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should it be Version 0.1.0 or Version 0.3.0? We released our V2 preview under 0.3.0.

Copy link
Member

Choose a reason for hiding this comment

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

@hvermis it should be 0.3.0 in that case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Identity = Identity
};

WriteObject(DataFactoryClient.UpdatePSDataFactory(parameters));
Copy link
Member

Choose a reason for hiding this comment

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

@hvermis looks like there is no ShouldProcess block wrapping this call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

HelpMessage = Constants.HelpIdentityForFactory)]
[Parameter(ParameterSetName = ParameterSetNames.ByResourceId, Position = 1, Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = Constants.HelpIdentityForFactory)]
public FactoryIdentity Identity { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@hvermis where is a user supposed to get this value from?

Copy link
Contributor Author

@hvermis hvermis Dec 1, 2017

Choose a reason for hiding this comment

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

This is one of the properties on data factory which gets created when they create a factory. The class is part of our SDK, and they can create a new instance of that class and pass it to update command, or they can get it from an existing factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the Value from pipeline to be by object. Here's an exampl of how it would look like:
(Get-AzureRmDataFactoryv2 -ResourceGroupName hvtest -DataFactoryName hvadf1).Identity|Update-AzureRmDataFactoryV
2 -DataFactoryName hvadf -ResourceGroupName hvtest

Is this worth supporting? Should I just remove the ValueFromPipeline completely?

Copy link
Member

Choose a reason for hiding this comment

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

@hvermis there currently exists a parameter set where DataFactory and Identity are in the same parameter set and both accept their value from the pipeline, which shouldn't happen. Only DataFactory should accept its value from the pipeline the in the parameter set, and we should look at ways of allowing the user to update the value of Identity.

HelpMessage = Constants.HelpTagsForFactory)]
public Hashtable Tag { get; set; }

[Parameter(ParameterSetName = ParameterSetNames.ByFactoryName, Position = 2, Mandatory = false, ValueFromPipelineByPropertyName = true,
Copy link
Member

Choose a reason for hiding this comment

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

@hvermis please remove the Position property from both Tag and Identity if they are optional parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

public Hashtable Tag { get; set; }

[Parameter(ParameterSetName = ParameterSetNames.ByFactoryName, Position = 2, Mandatory = false, ValueFromPipelineByPropertyName = true,
HelpMessage = Constants.HelpIdentityForFactory)]
Copy link
Member

Choose a reason for hiding this comment

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

@hvermis since Tag and Identity appear in all of the parameter sets and are optional, you can remove the multiple Parameter attributes that each one has and have only one Parameter attribute on each one, which will have no defined ParameterSetName

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -35,5 +36,14 @@ public abstract class DataFactoryContextBaseCmdlet: DataFactoryBaseCmdlet
HelpMessage = Constants.HelpFactoryName)]
[ValidateNotNullOrEmpty]
public string DataFactoryName { get; set; }

protected void ByFactoryObject(PSDataFactory dataFactory)
Copy link
Member

Choose a reason for hiding this comment

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

@hvermis why does dataFactory need to be passed in if you have a reference to DataFactory above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactoring issues - was trying to make more generic for other cmdlets too that have PSDatafactory called InputObject, and hit other issues. Removed it.

public string PipelineRunId { get; set; }

[Parameter(Mandatory = false, HelpMessage = Constants.HelpDontAskConfirmation)]
public SwitchParameter Force { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

@hvermis any reason you need to prompt the user for additional confirmation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but our other Stop- cmdlets also have this, and I was getting static analysis build failure, but them I found that if I leave ShouldProcess and remove -Force, the static analysis check passes. I will update this and other cmdlets.

```

### -Force
Don't ask for confirmation.```yaml
Copy link
Member

Choose a reason for hiding this comment

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

@hvermis make sure to move the trailing ```yaml string to a line by itself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Force is gone

@maddieclayton
Copy link
Contributor

@hvermis Some merge conflicts have come up, can you please resolve these?

@hvermis hvermis changed the base branch from preview to release-5.1.0 December 6, 2017 01:06
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.

@hvermis one minor comment, otherwise LGTM

@@ -0,0 +1,205 @@
---
external help file: Microsoft.Azure.Commands.DataFactoryV2.dll-Help.xml
online version:
Copy link
Member

Choose a reason for hiding this comment

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

@hvermis for the two cmdlets you are adding, can you make sure that the online version is set to the following URL:

https://docs.microsoft.com/en-us/powershell/module/azurerm.datafactories/<cmdlet_name>

All existing cmdlet markdown files have this field, so feel free to use them as an example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@cormacpayne
Copy link
Member

@cormacpayne cormacpayne merged commit d004c02 into Azure:release-5.1.0 Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants