-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Powershell for Management Groups #5421
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
Powershell for Management Groups #5421
Conversation
Bring preview branch up to date
Update preview branch after 5.0.0 release
…Subscription where SubscriptionId was accidentally SubscriptonId.
… to auto register.
… into powershell-for-groupsrp
cormacpayne
left a 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.
@rajshah11 a few initial comments to take a look at
| @@ -2,4224 +2,256 @@ | |||
| <Include xmlns="http://schemas.microsoft.com/wix/2006/wi"> | |||
| <Fragment> | |||
| <DirectoryRef Id="PowerShellFolder"> | |||
| <Component Id="cmp146D4BC76FE0B2425722E32B160714B3" Guid="*"> | |||
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.
@rajshah11 it looks like the wix file was incorrectly generated -- you will need to do a full build and then generate this file. Information about generating the wxi file can be found here.
| # ProcessorArchitecture = '' | ||
|
|
||
| # Modules that must be imported into the global environment prior to importing this module | ||
| RequiredModules = @(@{ModuleName = 'AzureRM.Profile'; ModuleVersion = '4.0.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.
@rajshah11 please make sure to pull the latest changes from the preview branch. The latest version of AzureRM.Profile that your module should be referencing is 4.2.0
| # IconUri = '' | ||
|
|
||
| # ReleaseNotes of this module | ||
| ReleaseNotes = '* Add support for online help |
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.
@rajshah11 you can leave the ReleaseNotes field blank for now -- we will update it before this is released
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.
@rajshah11 ping on this 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.
Done. Thanks!
| // You can specify all the values or you can default the Build and Revision Numbers | ||
| // by using the '*' as shown below: | ||
| // [assembly: AssemblyVersion("1.0.*")] | ||
| [assembly: AssemblyVersion("1.0.0.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.
@rajshah11 for consistency, AssemblyVersion and AssemblyFileVersion should match the version of your module (0.0.1)
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. Thanks!
| /// <summary> | ||
| /// Get-AzureRmManagementGroup Cmdlet | ||
| /// </summary> | ||
| [Cmdlet(VerbsCommon.Get,"AzureRmManagementGroup", DefaultParameterSetName = Constants.ParameterSetNames.GroupOperationsParameterSet, SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium), OutputType(typeof(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.
@rajshah11 please remove the ConfirmImpact property
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. Thanks!
| <WarningLevel>4</WarningLevel> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Reference Include="Hyak.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
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.
@rajshah11 please import the Common.Dependencies.targets file, like so. This will allow you to remove almost all of the packages you are referencing in this 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.
Done. Thanks!!
| <Link>AzureRM.ManagementGroups.psd1</Link> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
| <None Include="app.config" /> |
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.
@rajshah11 please remove this reference to app.config
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.
| </ItemGroup> | ||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
| <Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" /> | ||
| <Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''"> |
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.
@rajshah11 you can remove this Bcl target
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.
| // You can specify all the values or you can default the Build and Revision Numbers | ||
| // by using the '*' as shown below: | ||
| // [assembly: AssemblyVersion("1.0.*")] | ||
| [assembly: AssemblyVersion("1.0.0.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.
@rajshah11 same comment about keeping this values in line with the module 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.
Done.
| @@ -0,0 +1,18 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <packages> | |||
| <package id="Hyak.Common" version="1.0.2" targetFramework="net452" /> | |||
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.
@rajshah11 similarly to your .csproj file, you can remove all of the common packages (it should be everything but the Microsoft.Azure.Management.ResourceManager package)
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.
|
@rajshah11 Hey Raj, the build is currently failing because it cannot find version 1.7.0-preview of (1) If your changes are merged into the .NET SDK repository and the package is ready to be published, you can publish it to NuGet (2) Create a signed NuGet package that you can place in |
…nto powershell-for-groupsrp
…nto powershell-for-groupsrp
cormacpayne
left a 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.
@rajshah11 a few more comments to take a look at. Also,
(1) Make sure to update the TestMappings.json file to include an entry for your tests
(2) Once the Microsoft.Azure.Management.ResourceManager SDK is published with your changes, we should look at reverting the changes you made to external projects that update the version of this SDK used
| # IconUri = '' | ||
|
|
||
| # ReleaseNotes of this module | ||
| ReleaseNotes = '* Add support for online help |
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.
@rajshah11 ping on this comment
| - Run Get-Help with the -Online parameter to open the online help in your default Internet browser' | ||
|
|
||
| # External dependent modules of this module | ||
| # ExternalModuleDependencies = '' |
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.
@rajshah11 if you updated your version of the PowerShellGet module to 1.6.0, you'll be able to update this module to include the Prerelease property, which you will want to set to preview. Here is an example of a module doing this.
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. Thanks.
|
|
||
| function Test-ListManagementGroups | ||
| { | ||
| $response = Get-AzureRmManagementGroup |
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.
@rajshah11 for all of the below tests, please be sure the necessary setup is included in the tests (i.e., if anything needs to be created before Get-AzureRmManagementGroup is called, that should be included). This makes it easier for others to record these tests if needed.
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. Thanks!
|
|
||
| function Test-RemoveManagementGroup | ||
| { | ||
| $response = Remove-AzureRmManagementGroup -GroupName TestPSNewGroup3 |
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.
@rajshah11 same comment about necessary test setup
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. Thanks!
|
|
||
| function Test-UpdateManagementGroup | ||
| { | ||
| $response = Update-AzureRmManagementGroup -GroupName TestPSNewGroup3 |
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.
@rajshah11 same comment about including the necessary test setup for the below tests
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. Thanks!
| [Cmdlet(VerbsCommon.Remove, "AzureRmManagementGroup", | ||
| DefaultParameterSetName = Constants.ParameterSetNames.GroupOperationsParameterSet, | ||
| SupportsShouldProcess = true), OutputType(typeof(bool))] | ||
| public class RemoveAzureRmManagementGroup : AzureManagementGroupsCmdletBase |
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.
@rajshah11 this cmdlet should support the InputObject parameter set, so that a user could pipe the output of Get-AzureRmManagementGroup to this 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.
Done. Thanks
| { | ||
| if (context.Subscription.Id != SubscriptionId.ToString()) | ||
| { | ||
| Utility.AzureManagementGroupAutoRegisterSubscription(SubscriptionId.ToString(), context); |
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.
@rajshah11 same comment about if this is necessary
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.
@cormacpayne Replied above
| [Cmdlet(VerbsCommon.Remove, "AzureRmManagementGroupSubscription", | ||
| DefaultParameterSetName = Constants.ParameterSetNames.GroupOperationsParameterSet, | ||
| SupportsShouldProcess = true), OutputType(typeof(bool))] | ||
| public class RemoveAzureRmManagementGroupSubscription : AzureManagementGroupAutoRegisterCmdletBase |
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.
@rajshah11 same comment about supporting the InputObject 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.
We don't have a Get for subscription in a group. I don't think piping should be supported here. Correct me if I am wrong. Thanks
| namespace Microsoft.Azure.Commands.ManagementGroups.Cmdlets | ||
| { | ||
| [Cmdlet("Update", "AzureRmManagementGroup", DefaultParameterSetName = Constants.ParameterSetNames.GroupOperationsParameterSet, SupportsShouldProcess = true), OutputType(typeof(PSManagementGroupNoChildren))] | ||
| public class UpdateAzureRmManagementGroup : AzureManagementGroupsCmdletBase |
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.
@rajshah11 same comment about supporting the InputObject 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.
Done. Thanks
| </ItemGroup> | ||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
| <Import Project="..\..\..\..\tools\Common.Dependencies.targets" /> | ||
| <Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" /> |
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.
@rajshah11 you should be able to remove this import
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. Thanks
|
@cormacpayne made all the changes and the build is passing too. Just FYI we have moved out of the ResourceManager SDK for a SDK of our own. I have reverted the package references changes and made the new changes accordingly |
This reverts commit f5332f5.
|
Closing in favor of the new PR |
Description
This PR includes cmdlets and tests for Management Groups.
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
ShouldProcessand haveSupportShouldProcess=truespecified in the cmdlet attribute. You can find more information onShouldProcesshere.OutputTypeattribute if any output is produced - if the cmdlet produces no output, it should implement aPassThruparameter.Cmdlet Parameter Guidelines