Skip to content

Commit 7c667ef

Browse files
Adding Deployment Stacks cmdlet Implementations to Az.Resources (Azure#22019)
* Squashed commit of the following: commit 2ae973a Author: Dante Dalla Gasperina <[email protected]> Date: Fri Apr 21 15:58:48 2023 -0700 changing up test templates to avoid RG deletes, halving execution time commit dd4f283 Author: Dante Dalla Gasperina <[email protected]> Date: Thu Apr 20 14:06:19 2023 -0700 updating scenario tests commit 0e1d4bd Author: Dante Dalla Gasperina <[email protected]> Date: Tue Apr 11 10:08:29 2023 -0700 updated tests for required denysettings mode commit 18e8df2 Author: Dante Dalla Gasperina <[email protected]> Date: Tue Apr 11 09:32:36 2023 -0700 make DenySettingsMode required in new/set commands commit 57f735f Author: Dante Dalla Gasperina <[email protected]> Date: Thu Mar 23 10:27:15 2023 -0700 revert test file commit 01217c2 Author: Dante Dalla Gasperina <[email protected]> Date: Thu Mar 23 09:51:07 2023 -0700 cleaning up snapsnot code and unused imports commit 1c33c08 Author: Dante Dalla Gasperina <[email protected]> Date: Wed Mar 22 16:20:08 2023 -0700 more cleanup of unintended changes commit dc92cd1 Author: Dante Dalla Gasperina <[email protected]> Date: Wed Mar 22 15:59:38 2023 -0700 add back placeholder in local folder commit e09eb86 Author: Dante Dalla Gasperina <[email protected]> Date: Wed Mar 22 15:56:35 2023 -0700 cleaning up powershell repo commit 5ba8e31 Author: Gokul Premraj <[email protected]> Date: Mon Mar 20 15:04:20 2023 -0400 Modify SDKClient constructor to be private commit 38d8421 Author: Gokul Premraj <[email protected]> Date: Thu Mar 9 16:21:45 2023 -0500 Enable verbose dpeloyment operation logging and make it best effort commit 0380907 Author: Gokul Premraj <[email protected]> Date: Thu Oct 27 12:57:37 2022 -0400 Poll deployment operations to ensure -Verbose parity with deployments cmdlets commit 4e079f4 Author: Dante Dalla Gasperina <[email protected]> Date: Mon Feb 13 14:46:14 2023 -0800 Fixed management group remove by id parameter set commit 5d6a1a9 Author: Dante Dalla Gasperina <[email protected]> Date: Mon Feb 13 13:43:13 2023 -0800 finalizing management group scenario testing commit a65ba9b Author: Dante Dalla Gasperina <[email protected]> Date: Wed Feb 8 14:45:39 2023 -0800 updated resources ps1xml file commit 8cbe578 Author: Dante Dalla Gasperina <[email protected]> Date: Wed Feb 1 13:48:18 2023 -0800 adding resources view file changes commit 187764d Author: Dante Dalla Gasperina <[email protected]> Date: Wed Feb 1 13:46:52 2023 -0800 changes for incremental release commit b66a5fc Author: Dante Dalla Gasperina <[email protected]> Date: Thu Jan 26 15:52:52 2023 -0800 update tag view commit 616f7fd Author: Dante Dalla Gasperina <[email protected]> Date: Thu Jan 26 10:45:49 2023 -0800 adding tags commit c1bd480 Author: Dante Dalla Gasperina <[email protected]> Date: Thu Dec 29 11:58:25 2022 -0800 adding marksdown files for stack commands commit 24f41bb Author: Dante Dalla Gasperina <[email protected]> Date: Wed Dec 14 15:44:49 2022 -0800 Remove data plane actions from deny settings parameters commit 96842f0 Author: Dante Dalla Gasperina <[email protected]> Date: Tue Dec 13 13:43:02 2022 -0800 small test change commit 61358aa Author: Dante Dalla Gasperina <[email protected]> Date: Tue Dec 13 13:40:20 2022 -0800 checking in session records for rg and sub stack tests commit 35acd23 Author: Dante Dalla Gasperina <[email protected]> Date: Mon Dec 12 19:33:19 2022 -0800 adjusting scenario tests commit f786b99 Author: Dante Dalla Gasperina <[email protected]> Date: Mon Nov 28 16:20:45 2022 -0800 working on final changes to commands commit deb54e3 Author: Dante Dalla Gasperina <[email protected]> Date: Mon Nov 21 13:54:51 2022 -0800 working on cmdlets commit 27505b6 Author: Dante Dalla Gasperina <[email protected]> Date: Fri Nov 4 08:58:51 2022 -0700 running/saving scenario test runs commit a3fc9e7 Author: Dante Dalla Gasperina <[email protected]> Date: Wed Nov 2 11:46:36 2022 -0700 working on testing and small bug fixes commit 415c284 Author: Dante Dalla Gasperina <[email protected]> Date: Thu Oct 27 09:53:03 2022 -0700 refactoring tests commit 042bfe5 Author: Dante Dalla Gasperina <[email protected]> Date: Mon Oct 24 15:17:51 2022 -0700 adjusted confirmation message in remove/new commit 5dfe415 Author: Dante Dalla Gasperina <[email protected]> Date: Mon Oct 24 13:56:58 2022 -0700 more work with bugbash fixes commit 19febbc Author: Dante Dalla Gasperina <[email protected]> Date: Wed Oct 12 21:37:15 2022 -0700 Resolving bug bash issues commit 0c7d8a1 Author: Dante Dalla Gasperina <[email protected]> Date: Thu Oct 6 15:51:54 2022 -0700 working on refactor of DeploymentScope commit f389059 Author: Dante Dalla Gasperina <[email protected]> Date: Wed Sep 28 12:38:19 2022 -0700 Implementing rest of stacks commands and tests commit dfaf63f Author: Gokul Premraj <[email protected]> Date: Fri Sep 30 12:11:10 2022 -0400 Test cases + fixed bicep function commit 20c328a Author: Gokul Premraj <[email protected]> Date: Wed Sep 28 14:05:14 2022 -0400 Fixed broken DeploymentStackTests commit 9ff034a Merge: da5af36 0414344 Author: Gokul Premraj <[email protected]> Date: Wed Sep 28 14:01:36 2022 -0400 Merge branch 'DeploymentStacks' of https://github.com/Xynoclafe/azure-powershell into DeploymentStacks commit da5af36 Author: Gokul Premraj <[email protected]> Date: Wed Sep 28 11:33:45 2022 -0400 Bicep support for DeploymentStacks commit 0414344 Author: Dante Dalla Gasperina <[email protected]> Date: Wed Sep 28 08:22:03 2022 -0700 more work on commands commit 315809f Author: Dante Dalla Gasperina <[email protected]> Date: Mon Sep 26 15:23:45 2022 -0700 working on implementing commands commit ca9a340 Merge: 8c8713e 0f22721 Author: Gokul Premraj <[email protected]> Date: Mon Sep 26 15:27:29 2022 -0400 Merge branch 'main' of https://github.com/Azure/azure-powershell into DeploymentStacks commit 6aff57e Author: Dante Dalla Gasperina <[email protected]> Date: Wed Sep 21 15:57:00 2022 -0700 initial work on new stacks api commit 539efb8 Author: Harsh Patel <[email protected]> Date: Thu Jun 16 12:43:26 2022 -0400 Updated module number to 9.0.2 for release commit 3628d39 Author: Harsh Patel <[email protected]> Date: Wed May 4 12:00:28 2022 -0400 Updated the moduleversion commit 73375f6 Author: Harsh Patel <[email protected]> Date: Mon May 2 16:11:03 2022 -0400 nit changes commit 208a8cb Author: Harsh Patel <[email protected]> Date: Mon May 2 15:46:12 2022 -0400 New scenario tests commit d491dda Author: Harsh Patel <[email protected]> Date: Fri Apr 22 11:57:57 2022 -0400 Fixed nit, 2 tests still failing commit 8c814d7 Author: Harsh Patel <[email protected]> Date: Thu Apr 21 16:55:32 2022 -0400 Stacks now outputs errors correctly, 2 tests failing commit 8c8713e Author: Gokul Premraj <[email protected]> Date: Thu Nov 11 19:23:58 2021 -0500 Corrected Az.Resources manifest to include stacks cmdlets commit cd0272d Merge: b3db00c aa9d801 Author: Gokul Premraj <[email protected]> Date: Thu Nov 11 17:46:55 2021 -0500 merge fixes commit b3db00c Author: Gokul Premraj <[email protected]> Date: Thu Nov 11 17:42:46 2021 -0500 Added piping support and real time debug/verbose logs. Updated Version to avoid collision. Re-recorded tests commit a5a72bd Author: Gokul Premraj <[email protected]> Date: Tue Oct 19 16:12:50 2021 -0400 Removed purge delete flag commit 648a131 Author: Gokul Premraj <[email protected]> Date: Fri Oct 8 18:30:42 2021 -0400 Parameter renames commit bdc63c3 Author: Gokul Premraj <[email protected]> Date: Tue Sep 21 17:14:17 2021 -0400 Updated error messages; Removed scope-less aliases; changed -Purge to -PurgeResources in Remove-Az* cmdlets commit ea93530 Author: Gokul Premraj <[email protected]> Date: Wed Sep 15 17:46:18 2021 -0400 Updated SDK to fix parsing of FailedResources and updated output formatting commit 923e518 Author: Gokul Premraj <[email protected]> Date: Mon Sep 13 18:35:33 2021 -0400 few parameter names changed, new parameter -TemplateParameterObject added and few other fixes commit 15f8462 Author: Gokul Premraj <[email protected]> Date: Wed Sep 8 16:02:41 2021 -0400 Change updateBehavior to enum commit 878e38d Merge: 2409dc4 e251542 Author: Gokul Premraj <[email protected]> Date: Tue Sep 7 13:00:32 2021 -0400 merge upstream commit 2409dc4 Author: Gokul Premraj <[email protected]> Date: Tue Sep 7 12:31:24 2021 -0400 Fix API version used for polling cascade delete requests commit ff198c3 Author: Gokul Premraj <[email protected]> Date: Tue Aug 24 16:43:14 2021 -0400 Renamed some parameters commit 89258a1 Author: Gokul Premraj <[email protected]> Date: Mon Aug 16 18:22:21 2021 -0400 Fixed typo in detached resources preventing it from showing in output commit 260df64 Author: Gokul Premraj <[email protected]> Date: Mon Aug 16 18:05:11 2021 -0400 Modified New/Set cmdlet confirmation messages to use DeploymentStack instead of Stack commit 83e5ec7 Merge: a8c415b 150c6f1 Author: Gokul Premraj <[email protected]> Date: Thu Aug 12 17:58:15 2021 -0400 Re-record tests commit a8c415b Author: Gokul Premraj <[email protected]> Date: Thu Aug 12 15:41:08 2021 -0400 Added -AsJOb to New and Set cmdlets and more terminating statuses for polling commit 150c6f1 Author: Harsh Patel <[email protected]> Date: Thu Aug 12 13:08:16 2021 -0400 Added deployment scope paramter to new and set RG & sub [Needs testing] commit 082c08e Merge: 6a43c15 299d04b Author: Gokul Premraj <[email protected]> Date: Wed Aug 11 19:03:55 2021 -0400 Merge branch 'DeploymentStacks' of https://github.com/Xynoclafe/azure-powershell into DeploymentStacks commit 6a43c15 Author: Gokul Premraj <[email protected]> Date: Wed Aug 11 19:03:48 2021 -0400 Added optional -UpdateBehavior for New cmdlets and added polling to New and Set cmdlets commit 299d04b Author: Harsh Patel <[email protected]> Date: Wed Aug 11 12:48:51 2021 -0400 Moved scenario tests to the playback directory, all tests accept for NewAndSet for RG and Sub pass commit 0b8f12c Author: Gokul Premraj <[email protected]> Date: Tue Aug 10 18:30:48 2021 -0400 Fix build failures commit 3912597 Author: Harsh Patel <[email protected]> Date: Tue Aug 10 17:34:05 2021 -0400 Finished testing Scenario test [need to do playback] commit d733b01 Author: Gokul Premraj <[email protected]> Date: Tue Aug 10 14:05:06 2021 -0400 Add StackName alias to -Name parameter commit f9b0647 Author: Gokul Premraj <[email protected]> Date: Fri Aug 6 14:44:45 2021 -0400 Test recordings commit 5b61d41 Author: Gokul Premraj <[email protected]> Date: Thu Aug 5 17:47:26 2021 -0400 Test recording - subscriptionSnapshotGet commit 5c9df43 Author: Gokul Premraj <[email protected]> Date: Thu Aug 5 16:50:06 2021 -0400 Test recording - subscriptionGet commit eb5373d Author: Gokul Premraj <[email protected]> Date: Thu Aug 5 16:15:30 2021 -0400 Test fixes and recordings commit df3085a Merge: 2132b7c b2d4db2 Author: Gokul Premraj <[email protected]> Date: Mon Aug 2 12:17:52 2021 -0700 Merge branch 'DeploymentStacks' of https://github.com/Xynoclafe/azure-powershell into DeploymentStacks commit 2132b7c Author: Gokul Premraj <[email protected]> Date: Mon Aug 2 12:17:28 2021 -0700 Updated SDK + purge delete support commit b2d4db2 Author: Harsh Patel <[email protected]> Date: Fri Jul 30 15:07:59 2021 -0400 Fixed provisionState check for the NewAndSet tests with template specs commit 10213b1 Merge: 06ef7f8 5371cee Author: Gokul Premraj <[email protected]> Date: Fri Jul 30 11:51:45 2021 -0700 Merge branch 'Azure:main' into DeploymentStacks commit 06ef7f8 Author: Harsh Patel <[email protected]> Date: Fri Jul 30 11:55:36 2021 -0400 Finished Test-NewAndSetSubscriptionDeploymentStackWithTemplateSpec [Needs testing] commit 8b872f6 Author: Harsh Patel <[email protected]> Date: Thu Jul 29 18:17:17 2021 -0400 Finished Test-NewAndSetResourceGroupDeploymentStackWithTemplateSpec [Needs Testing] commit 87968fb Author: Gokul Premraj <[email protected]> Date: Tue Jul 27 15:51:21 2021 -0700 Improved errors + updated SDK commit 3f8542f Author: Gokul Premraj <[email protected]> Date: Mon Jul 26 16:48:46 2021 -0700 Removed hard gates from new and set cmdlets commit a561d3f Author: Gokul Premraj <[email protected]> Date: Mon Jul 26 13:13:08 2021 -0700 Included the new test scripts into test runner commit 1c84b1e Merge: 1d4bb71 f258ced Author: Gokul Premraj <[email protected]> Date: Mon Jul 26 14:33:15 2021 -0400 Merge branch 'Azure:main' into DeploymentStacks commit 1d4bb71 Author: Harsh Patel <[email protected]> Date: Thu Jul 22 13:24:19 2021 -0400 Finished Test-SetSubscriptionDeploymentStack & Test-SetResourceGroupDeploymentStack [Needs testings] commit a57da58 Author: Harsh Patel <[email protected]> Date: Thu Jul 22 11:05:35 2021 -0400 Finished Test-RemoveResourceGroupDeploymentStackSnapshot [Needs Testing] commit 208b9f9 Author: Harsh Patel <[email protected]> Date: Thu Jul 22 10:49:01 2021 -0400 Finished Test-RemoveSubscriptionDeploymentStackSnapshot [Needs Testing] commit e5b53eb Author: Harsh Patel <[email protected]> Date: Wed Jul 21 18:15:46 2021 -0400 Small edits commit c1f92bb Author: Harsh Patel <[email protected]> Date: Tue Jul 20 17:55:06 2021 -0400 Further changes to Test-NewSubscriptionDeploymentStack commit d2356ad Author: Harsh Patel <[email protected]> Date: Tue Jul 20 17:53:30 2021 -0400 Finished Test-NewSubscriptionDeploymentStack [Needs Review] commit 77a202d Author: Harsh Patel <[email protected]> Date: Tue Jul 20 16:15:06 2021 -0400 Finished Test-NewResourceGroupDeploymentStack commit eea37a8 Author: Harsh Patel <[email protected]> Date: Fri Jul 16 13:44:39 2021 -0400 Updated Test-GetResourceGroupDeploymentStackSnapshot commit 74efcff Author: Gokul Premraj <[email protected]> Date: Thu Jul 15 18:05:31 2021 -0400 clarify error messages and format console output commit 625a946 Merge: 6f26ce8 d4e45c6 Author: Gokul Premraj <[email protected]> Date: Mon Jul 12 16:54:30 2021 -0400 Merge branch 'DeploymentStacks' of https://github.com/Xynoclafe/azure-powershell into DeploymentStacks commit 6f26ce8 Author: Gokul Premraj <[email protected]> Date: Mon Jul 12 16:51:02 2021 -0400 Fix Get-subscription cmdlets commit d4e45c6 Author: Harsh Patel <[email protected]> Date: Mon Jul 12 12:54:27 2021 -0400 Finished Test-RemoveResourceGroupDeploymentStack [Needs Testing] commit 9fe082c Author: Harsh Patel <[email protected]> Date: Fri Jul 9 16:48:42 2021 -0400 Started on Remove Scenario Tests commit dfac372 Author: Harsh Patel <[email protected]> Date: Thu Jul 8 14:52:04 2021 -0400 Finished Test-GetResourceGroupDeploymentStackSnapshot function [Needs testing] commit 85e6b5f Author: Gokul Premraj <[email protected]> Date: Wed Jul 7 18:35:53 2021 -0400 Fix snapshot cmdlets commit d902ce1 Author: Harsh Patel <[email protected]> Date: Wed Jul 7 16:53:57 2021 -0400 Finished GetAzResourceGroupDeploymentStackSnapshot [Needs further testing] commit caebb5c Merge: da36bc2 2996019 Author: Gokul Premraj <[email protected]> Date: Tue Jul 6 12:19:11 2021 -0400 Merge branch 'DeploymentStacks' of https://github.com/Xynoclafe/azure-powershell into DeploymentStacks commit da36bc2 Author: Gokul Premraj <[email protected]> Date: Tue Jul 6 12:19:04 2021 -0400 Bug fixes commit 2996019 Author: Harsh Patel <[email protected]> Date: Tue Jul 6 11:43:50 2021 -0400 Finished GetAzResourceGroupDeploymentStack cmdnlet [Not tested] commit 3e51378 Author: Gokul Premraj <[email protected]> Date: Thu Jul 1 19:35:22 2021 -0400 Added stack existence checks for New- and Set- commit d3743a2 Author: Gokul Premraj <[email protected]> Date: Thu Jul 1 16:31:02 2021 -0400 Export cmdlets and fix bugs commit 0ea9a21 Author: Gokul Premraj <[email protected]> Date: Thu Jun 24 16:20:55 2021 -0400 Add remaining cmdlets commit 592eaf7 Author: Gokul Premraj <[email protected]> Date: Tue Jun 22 11:47:56 2021 -0400 Added New cmdlets commit 36de8c3 Merge: ea8e8b3 87067f8 Author: Gokul Premraj <[email protected]> Date: Mon Jun 21 16:06:46 2021 -0400 Merge branch 'Azure:main' into DeploymentStacks commit ea8e8b3 Author: Gokul Premraj <[email protected]> Date: Thu Jun 17 16:09:35 2021 -0400 stacks initial commit * connect stacks to new checked in sdk * Updates to cmdlets for bicep params and query string * taking params and param sets out of set/create commands in stacks * refactor cmdlets to be more straightforward * changes for sdk * adding the sdk generated files for stacks * reverting some unexpected changes and adding headers * Updated session records * remove unused parameter * updated changelog * Update markdown files for stack cmdlets * updated the help documents * updates to make cmdlets preview and addressing comments * Corrected plural parameter names and regenerated help files * Fixed satic analysis issues in help files * Remove PS prompt from help examples * Change -Name parameter to -StackName in Export cmdlets * Rename Export cmdlets to Save * Remove unnecessary changes from csproj files * Update the help files of export cmdlets to use save verbage instead of export * changing 'export' method name to 'save' --------- Co-authored-by: Gokul Premraj <[email protected]>
1 parent c97dfcb commit 7c667ef

File tree

135 files changed

+300850
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+300850
-12
lines changed

src/Accounts/Accounts/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Accounts/Authentication.ResourceManager/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Resources/ResourceManager/Components/ResourceIdentifier.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class ResourceIdentifier
3131

3232
public string Subscription { get; set; }
3333

34+
public string ManagementGroupName { get; set; }
35+
3436
public ResourceIdentifier() { }
3537

3638
public ResourceIdentifier(string idFromServer)
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
16+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkClient;
17+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Utilities;
18+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
19+
using System.Collections;
20+
21+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
22+
{
23+
public abstract class DeploymentStacksCmdletBase : ResourceManagerCmdletBase
24+
{
25+
26+
/// <summary>
27+
/// Deployment stacks client instance field
28+
/// </summary>
29+
private DeploymentStacksSdkClient deploymentStacksSdkClient;
30+
31+
/// <summary>
32+
/// Gets or sets the deployment stacks sdk client
33+
/// </summary>
34+
public DeploymentStacksSdkClient DeploymentStacksSdkClient
35+
{
36+
get
37+
{
38+
if (this.deploymentStacksSdkClient == null)
39+
{
40+
this.deploymentStacksSdkClient = new DeploymentStacksSdkClient(DefaultContext);
41+
}
42+
43+
this.deploymentStacksSdkClient.VerboseLogger = WriteVerboseWithTimestamp;
44+
this.deploymentStacksSdkClient.ErrorLogger = WriteErrorWithTimestamp;
45+
this.deploymentStacksSdkClient.WarningLogger = WriteWarningWithTimestamp;
46+
47+
return this.deploymentStacksSdkClient;
48+
}
49+
50+
set
51+
{
52+
this.deploymentStacksSdkClient = value;
53+
}
54+
}
55+
56+
protected string ResolveBicepFile(string TemplateFile)
57+
{
58+
if (BicepUtility.IsBicepFile(TemplateFile))
59+
{
60+
return BicepUtility.BuildFile(this.ResolvePath(TemplateFile), this.WriteVerbose, this.WriteWarning);
61+
}
62+
else
63+
return TemplateFile;
64+
65+
}
66+
67+
protected string ResolveBicepParameterFile(string TemplateParameterFile)
68+
{
69+
if (BicepUtility.IsBicepparamFile(TemplateParameterFile))
70+
{
71+
return BicepUtility.BuildParamFile(this.ResolvePath(TemplateParameterFile), this.WriteVerbose, this.WriteWarning);
72+
}
73+
else
74+
return TemplateParameterFile;
75+
}
76+
77+
protected Hashtable GetParameterObject(string parameterFile)
78+
{
79+
var parameters = new Hashtable();
80+
string templateParameterFilePath = this.ResolvePath(parameterFile);
81+
if (parameterFile != null && FileUtilities.DataStore.FileExists(templateParameterFilePath))
82+
{
83+
var parametersFromFile = TemplateUtility.ParseTemplateParameterFileContents(templateParameterFilePath);
84+
parametersFromFile.ForEach(dp =>
85+
{
86+
var parameter = new Hashtable();
87+
if (dp.Value.Value != null)
88+
{
89+
parameter.Add("value", dp.Value.Value);
90+
}
91+
if (dp.Value.Reference != null)
92+
{
93+
parameter.Add("reference", dp.Value.Reference);
94+
}
95+
96+
parameters[dp.Key] = parameter;
97+
});
98+
}
99+
return parameters;
100+
}
101+
102+
protected Hashtable GetTemplateParameterObject(Hashtable templateParameterObject)
103+
{
104+
//create a new Hashtable so that user can re-use the templateParameterObject.
105+
var parameterObject = new Hashtable();
106+
foreach (var parameterKey in templateParameterObject.Keys)
107+
{
108+
// Let default behavior of a value parameter if not a KeyVault reference Hashtable
109+
var hashtableParameter = templateParameterObject[parameterKey] as Hashtable;
110+
if (hashtableParameter != null && hashtableParameter.ContainsKey("reference"))
111+
{
112+
parameterObject[parameterKey] = templateParameterObject[parameterKey];
113+
}
114+
else
115+
{
116+
parameterObject[parameterKey] = new Hashtable { { "value", templateParameterObject[parameterKey] } };
117+
}
118+
}
119+
return parameterObject;
120+
}
121+
}
122+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.Collections;
16+
using System.Management.Automation;
17+
18+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.CmdletBase
19+
{
20+
public class DeploymentStacksCreateCmdletBase : DeploymentStacksCmdletBase
21+
{
22+
#region Cmdlet Parameters and Parameter Set Definitions
23+
24+
protected string protectedTemplateUri;
25+
26+
protected DeploymentStacksCreateCmdletBase()
27+
{
28+
}
29+
30+
internal const string ParameterlessTemplateFileParameterSetName = "ByTemplateFileWithNoParameters";
31+
internal const string ParameterlessTemplateUriParameterSetName = "ByTemplateUriWithNoParameters";
32+
internal const string ParameterlessTemplateSpecParameterSetName = "ByTemplateSpecWithNoParameters";
33+
34+
internal const string ParameterFileTemplateFileParameterSetName = "ByTemplateFileWithParameterFile";
35+
internal const string ParameterFileTemplateUriParameterSetName = "ByTemplateUriWithParameterFile";
36+
internal const string ParameterFileTemplateSpecParameterSetName = "ByTemplateSpecWithParameterFile";
37+
38+
internal const string ParameterUriTemplateFileParameterSetName = "ByTemplateFileWithParameterUri";
39+
internal const string ParameterUriTemplateUriParameterSetName = "ByTemplateUriWithParameterUri";
40+
internal const string ParameterUriTemplateSpecParameterSetName = "ByTemplateSpecWithParameterUri";
41+
42+
internal const string ParameterObjectTemplateFileParameterSetName = "ByTemplateFileWithParameterObject";
43+
internal const string ParameterObjectTemplateUriParameterSetName = "ByTemplateUriWithParameterObject";
44+
internal const string ParameterObjectTemplateSpecParameterSetName = "ByTemplateSpecWithParameterObject";
45+
46+
[Parameter(ParameterSetName = ParameterFileTemplateFileParameterSetName,
47+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "TemplateFile to be used to create the stack.")]
48+
[Parameter(ParameterSetName = ParameterUriTemplateFileParameterSetName,
49+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "TemplateFile to be used to create the stack.")]
50+
[Parameter(ParameterSetName = ParameterObjectTemplateFileParameterSetName,
51+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "TemplateFile to be used to create the stack.")]
52+
[Parameter(ParameterSetName = ParameterlessTemplateFileParameterSetName,
53+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "TemplateFile to be used to create the stack.")]
54+
public string TemplateFile { get; set; }
55+
56+
[Parameter(ParameterSetName = ParameterFileTemplateUriParameterSetName,
57+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Location of the Template to be used to create the stack.")]
58+
[Parameter(ParameterSetName = ParameterUriTemplateUriParameterSetName,
59+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Location of the Template to be used to create the stack.")]
60+
[Parameter(ParameterSetName = ParameterObjectTemplateUriParameterSetName,
61+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Location of the Template to be used to create the stack.")]
62+
[Parameter(ParameterSetName = ParameterlessTemplateUriParameterSetName,
63+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Location of the Template to be used to create the stack.")]
64+
public string TemplateUri { get; set; }
65+
66+
[Parameter(ParameterSetName = ParameterFileTemplateSpecParameterSetName,
67+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceId of the TemplateSpec to be used to create the stack.")]
68+
[Parameter(ParameterSetName = ParameterUriTemplateSpecParameterSetName,
69+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceId of the TemplateSpec to be used to create the stack.")]
70+
[Parameter(ParameterSetName = ParameterObjectTemplateSpecParameterSetName,
71+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceId of the TemplateSpec to be used to create the stack.")]
72+
[Parameter(ParameterSetName = ParameterlessTemplateSpecParameterSetName,
73+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "ResourceId of the TemplateSpec to be used to create the stack.")]
74+
public string TemplateSpecId { get; set; }
75+
76+
[Parameter(ParameterSetName = ParameterFileTemplateFileParameterSetName,
77+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Parameter file to use for the template.")]
78+
[Parameter(ParameterSetName = ParameterFileTemplateUriParameterSetName,
79+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Parameter file to use for the template.")]
80+
[Parameter(ParameterSetName = ParameterFileTemplateSpecParameterSetName,
81+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Parameter file to use for the template.")]
82+
public string TemplateParameterFile { get; set; }
83+
84+
[Parameter(ParameterSetName = ParameterUriTemplateFileParameterSetName,
85+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Location of the Parameter file to use for the template.")]
86+
[Parameter(ParameterSetName = ParameterUriTemplateUriParameterSetName,
87+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Location of the Parameter file to use for the template.")]
88+
[Parameter(ParameterSetName = ParameterUriTemplateSpecParameterSetName,
89+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Location of the Parameter file to use for the template.")]
90+
public string TemplateParameterUri { get; set; }
91+
92+
[Parameter(ParameterSetName = ParameterObjectTemplateFileParameterSetName,
93+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "A hash table which represents the parameters.")]
94+
[Parameter(ParameterSetName = ParameterObjectTemplateUriParameterSetName,
95+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "A hash table which represents the parameters.")]
96+
[Parameter(ParameterSetName = ParameterObjectTemplateSpecParameterSetName,
97+
Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "A hash table which represents the parameters.")]
98+
public Hashtable TemplateParameterObject { get; set; }
99+
100+
[Parameter(Mandatory = false, HelpMessage = "Skips the PowerShell dynamic parameter processing that checks if the provided template parameter contains all necessary parameters used by the template. " +
101+
"This check would prompt the user to provide a value for the missing parameters, but providing the -SkipTemplateParameterPrompt will ignore this prompt and " +
102+
"error out immediately if a parameter was found not to be bound in the template. For non-interactive scripts, -SkipTemplateParameterPrompt can be provided " +
103+
"to provide a better error message in the case where not all required parameters are satisfied.")]
104+
public SwitchParameter SkipTemplateParameterPrompt { get; set; }
105+
106+
[Parameter(Mandatory = false, HelpMessage = "The query string (for example, a SAS token) to be used with the TemplateUri parameter. Would be used in case of linked templates")]
107+
public string QueryString { get; set; }
108+
109+
#endregion
110+
}
111+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation
16+
{
17+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
18+
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels;
19+
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
20+
using System;
21+
using System.Management.Automation;
22+
23+
[Cmdlet("Get", Common.AzureRMConstants.AzureRMPrefix + "ManagementGroupDeploymentStack",
24+
DefaultParameterSetName = ListByManagementGroupIdParameterSetName), OutputType(typeof(PSDeploymentStack))]
25+
[CmdletPreview("The cmdlet is in preview and under development.")]
26+
public class GetAzManagementGroupDeploymentStack : DeploymentStacksCmdletBase
27+
{
28+
#region Cmdlet Parameters and Parameter Set Definitions
29+
30+
internal const string GetByResourceIdParameterSetName = "GetByResourceId";
31+
internal const string GetByManagementGroupIdAndNameParameterSetName = "GetByManagementGroupIdAndName";
32+
internal const string ListByManagementGroupIdParameterSetName = "ListByManagmentGroupId";
33+
34+
[Alias("StackName")]
35+
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = GetByManagementGroupIdAndNameParameterSetName,
36+
HelpMessage = "The name of the DeploymentStack to get")]
37+
[ValidateNotNullOrEmpty]
38+
public string Name { get; set; }
39+
40+
[Alias("Id")]
41+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = GetByResourceIdParameterSetName,
42+
HelpMessage = "ResourceId of the DeploymentStack to get")]
43+
[ValidateNotNullOrEmpty]
44+
public string ResourceId { get; set; }
45+
46+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ListByManagementGroupIdParameterSetName,
47+
HelpMessage = "The id of the ManagementGroup where the DeploymentStack is deployed")]
48+
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = GetByManagementGroupIdAndNameParameterSetName,
49+
HelpMessage = "The id of the ManagementGroup where the DeploymentStack is deployed")]
50+
[ValidateNotNullOrEmpty]
51+
public string ManagementGroupId { get; set; }
52+
53+
#endregion
54+
55+
#region Cmdlet Overrides
56+
57+
protected override void OnProcessRecord()
58+
{
59+
try
60+
{
61+
this.GetResourcesClient();
62+
switch (ParameterSetName)
63+
{
64+
case GetByResourceIdParameterSetName:
65+
ManagementGroupId = ResourceIdUtility.GetManagementGroupId(ResourceId);
66+
Name = ResourceIdUtility.GetDeploymentName(ResourceId);
67+
if (ManagementGroupId == null || Name == null)
68+
{
69+
throw new PSArgumentException($"Provided Id '{ResourceId}' is not in correct form. Should be in form " +
70+
"/providers/Microsoft.Management/managementGroups/<managementgroupid>/providers/Microsoft.Resources/deploymentStacks/<stackname>");
71+
}
72+
WriteObject(DeploymentStacksSdkClient.GetManagementGroupDeploymentStack(ManagementGroupId, Name), true);
73+
break;
74+
case GetByManagementGroupIdAndNameParameterSetName:
75+
WriteObject(DeploymentStacksSdkClient.GetManagementGroupDeploymentStack(ManagementGroupId, Name, true));
76+
break;
77+
case ListByManagementGroupIdParameterSetName:
78+
WriteObject(DeploymentStacksSdkClient.ListManagementGroupDeploymentStack(ManagementGroupId), true);
79+
break;
80+
default:
81+
throw new PSInvalidOperationException();
82+
}
83+
}
84+
catch (Exception ex)
85+
{
86+
WriteExceptionError(ex);
87+
}
88+
}
89+
90+
#endregion
91+
}
92+
}

0 commit comments

Comments
 (0)