-
Notifications
You must be signed in to change notification settings - Fork 4k
[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
Conversation
@maddieclayton This PR also contains Cancel pipeline run, please review. |
There was a problem hiding this 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] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)] |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*pipeline
There was a problem hiding this 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} | |||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Force is gone
@hvermis Some merge conflicts have come up, can you please resolve these? |
There was a problem hiding this 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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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
Testing Guidelines
Cmdlet Signature Guidelines
ShouldProcess
and haveSupportShouldProcess=true
specified in the cmdlet attribute. You can find more information onShouldProcess
here.OutputType
attribute if any output is produced - if the cmdlet produces no output, it should implement aPassThru
parameter.Cmdlet Parameter Guidelines