-
Notifications
You must be signed in to change notification settings - Fork 4k
Support new cmdlets for subscription level deployment #6516
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
@Tiano2017 when you're ready for someone from our side to review this PR, please remove the |
Corresponding cmdlet design review: https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/102 |
@Tiano2017
|
@vladimir-shcherbakov sure I can do that, but should I do that after all issues are resolved? right now I still have CI failures which I'm trying to resolve. |
@Tiano2017 |
did the rebase. seems still got the failure. |
@vladimir-shcherbakov I've fixed the error on help files. Can you help take another look? |
@Tiano2017 Reason to fail for most of them is |
@cormacpayne can you please take another look? |
|
||
[Alias("DeploymentName")] | ||
[Parameter(Position = 0, ParameterSetName = GetAzureDeploymentCmdlet.DeploymentNameParameterSet, Mandatory = false, | ||
ValueFromPipelineByPropertyName = true, HelpMessage = "The name of deployment.")] |
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.
@Tiano2017 please remove the ValueFromPipelineByPropertyName
property from the -Name
parameter and move it to the -ResourceId
parameter so users can do the following:
Get-AzureRmResource -ResourceType Microsoft.Resources/deployments | Get-AzureRmDeployment
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.
we need it on the Name parameter for some other pipeline scenarios. As for Get-AzureRmResource, I don't think it returns "deployments" as resources. Strictly speaking, "deployment" is not a resource, although we implement the APIs to be consistent with resource APIs.
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.
@Tiano2017 this is deprecated - Piping by value is now the recommendation - if you can pipe the object associated with the cmdlet noun into the cmdlet no by-property-name piping (other than piping resourceid by property name) should be used.
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.
Sorry Mark.. I'm not quite getting the point. Are you recommending just removing this piping support?
In reply to: 207954017 [](ancestors = 207954017)
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.
As replied in the other comment, Get-AzureRmResource doesn't return deployments, as deployment is not a resource..
In reply to: 207688618 [](ancestors = 207688618)
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.
The ValueFromPipelineByPropertyName setting is still here. Remove. If you want to support piping from something, use a parameter set with a PSDeployment INputObject. In this case, you may not need piping.
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.
Also note - you should consider having a single parameter that would accept either Name or Id - then the user could pass in a fully qualified name or short name and you wouldn't need any parameter 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.
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.
We have these two parameters for Get-AzureRmResourceGroupDeployment. I think we can keep them to be consistent.
In reply to: 208427148 [](ancestors = 208427148)
public string Location { get; set; } | ||
|
||
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The deployment debug log level.")] | ||
[ValidateSet("RequestContent", "ResponseContent", "All", "None", IgnoreCase = 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.
@Tiano2017 we recommend using PSArgumentCompleter
since it allows for potential additions in the future and users don't notice a difference with the tab-completion
{ | ||
Location = Location, | ||
DeploymentName = Name, | ||
DeploymentMode = DeploymentMode.Incremental, |
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.
@Tiano2017 got it, thanks for clarifying
{ | ||
WriteWarning(ProjectResources.WarnOnDeploymentDebugSetting); | ||
} | ||
WriteObject(ResourceManagerSdkClient.ExecuteDeploymentAtSubscriptionScope(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.
@Tiano2017 you do it below for your Save-AzureRmDeployment
cmdlet 😀
public string Name { get; set; } | ||
|
||
[Alias("DeploymentId", "ResourceId")] | ||
[Parameter(ParameterSetName = RemoveAzureDeploymentCmdlet.DeploymentIdParameterSet, Mandatory = 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.
@Tiano2017 the result of Get-AzureRmDeployment
will be bound to the -InputObject
parameter. We want to enable the scenario (as mentioned above for Get-AzureRmDeployment
) where the user can pipe the result of Get-AzureRmResource
to a cmdlet and have the -ResourceId
bound, which is enable when you add the ValueFromPipelineByPropertyName
property to this parameter and remove it from the -Name
parameter.
[Parameter(ParameterSetName = RemoveAzureDeploymentCmdlet.InputObjectParameterSet, Mandatory = true, | ||
ValueFromPipeline = true, HelpMessage = "The deployment object.")] | ||
public PSDeployment InputObject { 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.
@Tiano2017 is the underlying operation long-running? If so, you might as well add the -AsJob
parameter to allow users to run this cmdlet in the background (at no cost 😉)
string.IsNullOrEmpty(this.Path) | ||
? System.IO.Path.Combine(CurrentPath(), deploymentName) | ||
: this.TryResolvePath(this.Path), | ||
overwrite: this.Force, |
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.
@Tiano2017 got it, thanks for clarifying
/// Saves the deployment template to a file on disk. | ||
/// </summary> | ||
[Cmdlet(VerbsData.Save, "AzureRmDeploymentTemplate", SupportsShouldProcess = true, | ||
DefaultParameterSetName = SaveAzureDeploymentTemplateCmdlet.DeploymentNameParameterSet), OutputType(typeof(PSObject))] |
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.
@Tiano2017 even if we are returning the file path, we should still have a concrete type with that path as one of its properties -- we are now generating docs for our types, which lets the user know what properties and methods are exposed on parameter and output types, and it is also best practice to use concrete .NET types in PowerShell for consistency in returned objects
/// <summary> | ||
/// Cancel a running deployment. | ||
/// </summary> | ||
[Cmdlet(VerbsLifecycle.Stop, "AzureRmDeployment", SupportsShouldProcess = 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.
@Tiano2017 got it. Maybe we should think about adding an alias for New-AzureRmDeployment
that is Start-AzureRmDeployment
? Something to think about
public string Name { get; set; } | ||
|
||
[Alias("DeploymentId", "ResourceId")] | ||
[Parameter(ParameterSetName = StopAzureDeploymentCmdlet.DeploymentIdParameterSet, Mandatory = 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.
@Tiano2017 same comment as above 😀
@@ -1391,13 +1391,13 @@ public void CancelsActiveDeployment() | |||
public void SerializeHashtableProperlyHandlesAllDataTypes() | |||
{ | |||
Hashtable hashtable = new Hashtable(); | |||
var password = "pass"; | |||
var pass = "pass"; | |||
hashtable.Add("key1", "string"); |
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.
@Tiano2017
The right way to avoid false positives matches is to use inline-suppressions.
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 one should be fine. It's a random variable, and doesn't have to be named "password".
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 have makred those places where there are still necessary changes.
|
||
[Alias("DeploymentName")] | ||
[Parameter(Position = 0, ParameterSetName = GetAzureDeploymentCmdlet.DeploymentNameParameterSet, Mandatory = false, | ||
ValueFromPipelineByPropertyName = true, HelpMessage = "The name of deployment.")] |
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.
The ValueFromPipelineByPropertyName setting is still here. Remove. If you want to support piping from something, use a parameter set with a PSDeployment INputObject. In this case, you may not need piping.
|
||
[Alias("DeploymentName")] | ||
[Parameter(Position = 0, ParameterSetName = GetAzureDeploymentCmdlet.DeploymentNameParameterSet, Mandatory = false, | ||
ValueFromPipelineByPropertyName = true, HelpMessage = "The name of deployment.")] |
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.
Also note - you should consider having a single parameter that would accept either Name or Id - then the user could pass in a fully qualified name or short name and you wouldn't need any parameter set.
/// <summary> | ||
/// Gets or sets the deployment name parameter. | ||
/// </summary> | ||
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The deployment name.")] |
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.
As discussed, these ValueFromPipelineByPropertyName settings should be removed.
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.
Removed. And added DepoymentObject parameter for piping scenario.
In reply to: 208427257 [](ancestors = 208427257)
public class NewAzureDeploymentCmdlet : ResourceWithParameterCmdletBase, IDynamicParameters | ||
{ | ||
[Alias("DeploymentName")] | ||
[Parameter(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.
same comment
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.
removed.
: !string.IsNullOrEmpty(this.Id) ? ResourceIdUtility.GetResourceName(this.Id) : this.InputObject.DeploymentName; | ||
|
||
ResourceManagerSdkClient.DeleteDeploymentAtSubscriptionScope(deploymentName); | ||
WriteObject(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.
This is not a good reason to continue a non-conforming pattern. You should return nothing on success, unless the user supplies -PassThru
/// <summary> | ||
/// Gets or sets the file path. | ||
/// </summary> | ||
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The output path of the template file.")] |
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.
same issue, remove the ValueFromPipelineByPropertyName setting for this parameter
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.
removed.
this.Name, | ||
() => ResourceManagerSdkClient.CancelDeploymentAtSubscriptionScope(deploymentName)); | ||
|
||
WriteObject(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.
No, we need to make this meet the design guidelines now.
Marked those places that still need to change
CI job is passing now. @markcowl please let me know if there's more changes required. |
Description
This PR adds new cmdlets for subscription level deployment.
Checklist
CONTRIBUTING.md
platyPS
module