Skip to content

EventHub: RP version 2017-04-01 and cmdlet recommendations #4307

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 17 commits into from
Aug 7, 2017

Conversation

v-Ajnava
Copy link

@v-Ajnava v-Ajnava commented Jul 13, 2017

Description

PR consist the changes related RP version 2017-04-01 and cmdlet recommendations from PowerShell review team.

RP version changes changes included 3 properties are marked as Obsolete and few properties added.
Recommendations include the 6 Namespace authorization rule cmdlet marked as Obsolete and

Updated Eventhub authorization rule cmdlet with Parameter sets to differentiate the authorization rule for Namespace and Eventhub.

renamed cmdlet parameters with recommended and added old names as alias.

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.

@markcowl
Copy link
Member

@v-Ajnava Test failures, please take a look

NuGet.config Outdated
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
Copy link
Member

Choose a reason for hiding this comment

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

Please do not change this

@@ -2,6 +2,12 @@
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="PowerShellFolder">
Copy link
Member

Choose a reason for hiding this comment

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

why are you changing this file? None of these changes are valid

/// 'Remove-AzureRmRelayAuthorizationRule' Cmdlet removes/deletes AuthorizationRule
/// </summary>
[Cmdlet(VerbsCommon.Remove, EventHubAuthorizationRuleVerb, DefaultParameterSetName = NamespaceAuthoRuleParameterSet, SupportsShouldProcess = true), OutputType(typeof(bool))]
public class RemoveAzureRelayAuthorizationRule : AzureEventHubsCmdletBase
Copy link
Member

Choose a reason for hiding this comment

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

class name should match file name

Copy link
Member

Choose a reason for hiding this comment

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

@v-Ajnava ^ ping on this comment

/// 'New-AzureRmRelayKey' Cmdlet creates a new specified (PrimaryKey / SecondaryKey) key for the given WcfRelay Authorization Rule
/// </summary>
[Cmdlet(VerbsCommon.New, EventHubKeyVerb, DefaultParameterSetName = NamespaceAuthoRuleParameterSet, SupportsShouldProcess = true), OutputType(typeof(AuthorizationRuleKeysAttributes))]
public class NewAzureRmRelayKey : AzureEventHubsCmdletBase
Copy link
Member

Choose a reason for hiding this comment

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

class name should match file name

/// 'New-AzureRmRelayAuthorizationRule' Cmdlet creates a new AuthorizationRule
/// </summary>
[Cmdlet(VerbsCommon.New, EventHubAuthorizationRuleVerb, DefaultParameterSetName = NamespaceAuthoRuleParameterSet, SupportsShouldProcess = true), OutputType(typeof(AuthorizationRuleAttributes))]
public class NewAzureRelayAuthorizationRule : AzureEventHubsCmdletBase
Copy link
Member

Choose a reason for hiding this comment

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

class name shoudl match file name

/// 'Set-AzureRmRelayAuthorizationRule' Cmdlet updates the specified AuthorizationRule
/// </summary>
[Cmdlet(VerbsCommon.Set, EventHubAuthorizationRuleVerb, DefaultParameterSetName = NamespaceAuthoRuleParameterSet, SupportsShouldProcess = true), OutputType(typeof(AuthorizationRuleAttributes))]
public class SetAzureRelayAuthorizationRule : AzureEventHubsCmdletBase
Copy link
Member

Choose a reason for hiding this comment

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

class name

<package id="Microsoft.Azure.Management.IotHub" version="1.1.2" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net452" />
Copy link
Member

Choose a reason for hiding this comment

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

why is this updated?

@@ -38,7 +38,7 @@ function Test-AzureRmIotHubLifecycle
$resourceGroup = New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location

Write-Debug " Create new eventHub "
$namespaceName = "IotHubPSEHNamespaceTest"
$namespaceName = "IotHubPSEHNamespaceTest1212"
Copy link
Member

Choose a reason for hiding this comment

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

why is this updated?

"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.EventHub.GetAzureRmEventHubAuthorizationRule","Get-AzureRmEventHubAuthorizationRule","0","2100","The parameter 'EventHubName' in cmdlet 'Get-AzureRmEventHubAuthorizationRule' is no longer in the parameter set '__AllParameterSets'.","Add parameter 'EventHubName' back to the parameter set '__AllParameterSets'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.EventHub.GetAzureEventHubKey","Get-AzureRmEventHubKey","0","1020","The cmdlet 'Get-AzureRmEventHubKey' no longer has output type 'Microsoft.Azure.Commands.EventHub.Models.ListKeysAttributes'.","Make cmdlet 'Get-AzureRmEventHubKey' return type 'Microsoft.Azure.Commands.EventHub.Models.ListKeysAttributes'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.EventHub.GetAzureEventHubKey","Get-AzureRmEventHubKey","0","2100","The parameter 'NamespaceName' in cmdlet 'Get-AzureRmEventHubKey' is no longer in the parameter set '__AllParameterSets'.","Add parameter 'NamespaceName' back to the parameter set '__AllParameterSets'."
Copy link
Member

Choose a reason for hiding this comment

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

Many of these look like actual breaking changes, which won't be accepted (for example, adding validation that wasn't ehere before)

@v-Ajnava
Copy link
Author

@markcowl , for IoT Hub test case failure, we synced with Iot Hub team @rmanda made the changes.

@cormacpayne
Copy link
Member

@v-Ajnava it looks like this PR is out of sync with the preview branch and is reverting a lot of merged changes. Please pull the latest changes from the preview branch.

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.

@v-Ajnava some comments that need to be resolved

@@ -19,7 +19,26 @@
-->
## Current Release

## Version 0.4.2
## Version 4.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.

@v-Ajnava please move the content below to under the Current Release header, and revert the changes made to Version 0.4.2 header

Copy link
Author

Choose a reason for hiding this comment

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

Resolved.

Write-Debug " Create new Evnethub namespace"
Write-Debug " Namespace name : $namespaceName"
$result = New-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -Name $namespaceName -Location $location
Wait-Seconds 15
Copy link
Member

Choose a reason for hiding this comment

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

@v-Ajnava why is this Wait-Seconds command needed?

Copy link
Author

Choose a reason for hiding this comment

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

Removed the wait command, used it for testing

Copy link
Member

Choose a reason for hiding this comment

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

not removed

Write-Debug "Namespace name : $namespaceName"

$result = New-AzureRmEventHubNamespace -ResourceGroup $resourceGroupName -Name $namespaceName -Location $location
Wait-Seconds 15
Copy link
Member

Choose a reason for hiding this comment

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

@v-Ajnava same comment

Copy link
Author

Choose a reason for hiding this comment

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

Removed the wait command, used it for testing

Copy link
Member

Choose a reason for hiding this comment

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

Not removed

ValueFromPipelineByPropertyName = true,
HelpMessage = "Rights, e.g. \"Listen\",\"Send\",\"Manage\"")]
[ValidateNotNullOrEmpty]
public string[] Rights { 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.

@v-Ajnava consider using ValidateSet if the values that you can provide for this parameter are restricted to a set of strings

Copy link
Author

Choose a reason for hiding this comment

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

added validate set

/// 'Remove-AzureRmRelayAuthorizationRule' Cmdlet removes/deletes AuthorizationRule
/// </summary>
[Cmdlet(VerbsCommon.Remove, EventHubAuthorizationRuleVerb, DefaultParameterSetName = NamespaceAuthoRuleParameterSet, SupportsShouldProcess = true), OutputType(typeof(bool))]
public class RemoveAzureRelayAuthorizationRule : AzureEventHubsCmdletBase
Copy link
Member

Choose a reason for hiding this comment

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

@v-Ajnava ^ ping on this comment

public string Location { get; set; }

[Parameter(Mandatory = true,
ValueFromPipelineByPropertyName = true,
Position = 3,
Position = 2,
Copy link
Member

Choose a reason for hiding this comment

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

@v-Ajnava why was this change made? You now have two parameters with the same position, which will cause an error

Copy link
Author

Choose a reason for hiding this comment

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

Reverted, by mistake

@@ -51,6 +53,7 @@ public class GetAzureEventHubNamespaceAuthorizationRule : AzureEventHubsCmdletBa

public override void ExecuteCmdlet()
{
// WriteWarning("'Get-AzureRmEventHubNamespaceAuthorizationRule' cmdlet is mark as obsolete and will be depricated in upcoming breaking changes build. Please use the New cmdlet 'Get-AzureRmEventHubAuthorizationRule'");
Copy link
Member

Choose a reason for hiding this comment

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

@v-Ajnava please remove this line if it's going to be commented out

Copy link
Author

Choose a reason for hiding this comment

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

Removed

Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Upper limit of throughput units when AutoInflate is enabled, vaule should be within 0 to 20 throughput units.")]
public int? MaximumThroughputUnits { 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.

@v-Ajnava please use ValidateSet if you're going to limit the value to be between 0-20

Also, there is a typo in the above HelpMessage: vaule should be value

Copy link
Author

Choose a reason for hiding this comment

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

For Validation I have used validate range.

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Upper limit of throughput units when AutoInflate is enabled, vaule should be within 0 to 20 throughput units.")]
Copy link
Member

Choose a reason for hiding this comment

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

@v-Ajnava what happens when this value is provided but AutoInflate is disabled?

Copy link
Author

Choose a reason for hiding this comment

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

when AutoInflate is disabled and try to set MaximumThroughputUnits is been, RP will return an error

Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Upper limit of throughput units when AutoInflate is enabled, vaule should be within 0 to 20 throughput units.")]
public int? MaximumThroughputUnits { 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.

@v-Ajnava same comments about ValidateSet, typo, and AutoInflate being disabled

Copy link
Author

Choose a reason for hiding this comment

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

when AutoInflate is disabled and try to set MaximumThroughputUnits is been, RP will return an error. For Validation I have used validate range.

@markcowl
Copy link
Member

@v-Ajnava This cmdlet is out of sync with the preview branch. Please merge - also, since you already have multiple merge commits, please clean up your commits.

@cormacpayne
Copy link
Member

@cormacpayne cormacpayne changed the base branch from preview to release-4.3.0 August 4, 2017 15:59
cormacpayne
cormacpayne previously approved these changes Aug 4, 2017
@@ -9,16 +9,22 @@ schema: 2.0.0
## SYNOPSIS
Updates the specified Event Hubs namespace.

## SYNTAX
Copy link
Member

Choose a reason for hiding this comment

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

@v-Ajnava the ## SYNTAX header should not have been removed

Copy link
Author

Choose a reason for hiding this comment

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

corrected the markdown

@cormacpayne
Copy link
Member

@cormacpayne
Copy link
Member

@azuresdkci test this please

@@ -218,6 +218,38 @@
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Network\Microsoft.Azure.Commands.Network.dll","Microsoft.Azure.Commands.Network.NewAzureLocalNetworkGatewayCommand","New-AzureRmLocalNetworkGateway","0","2020","The cmdlet 'New-AzureRmLocalNetworkGateway' no longer supports the type 'System.UInt32' for parameter 'Asn'.","Change the type for parameter 'Asn' back to 'System.UInt32'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Network\Microsoft.Azure.Commands.Network.dll","Microsoft.Azure.Commands.Network.SetAzureLocalNetworkGatewayCommand","Set-AzureRmLocalNetworkGateway","0","2020","The cmdlet 'Set-AzureRmLocalNetworkGateway' no longer supports the type 'System.UInt32' for parameter 'Asn'.","Change the type for parameter 'Asn' back to 'System.UInt32'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.Network\Microsoft.Azure.Commands.Network.dll","Microsoft.Azure.Commands.Network.ResetAzureVirtualNetworkGatewayConnectionSharedKeyCommand","Reset-AzureRmVirtualNetworkGatewayConnectionSharedKey","0","2020","The cmdlet 'Reset-AzureRmVirtualNetworkGatewayConnectionSharedKey' no longer supports the type 'System.UInt32' for parameter 'KeyLength'.","Change the type for parameter 'KeyLength' back to 'System.UInt32'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.Namespace.NewAzureRmEventHubKey","New-AzureRmEventHubKey","0","2000","The cmdlet 'New-AzureRmEventHubKey' no longer supports the parameter 'ResourceGroup' and no alias was found for the original parameter name.","Add the parameter 'ResourceGroup' back to the cmdlet 'New-AzureRmEventHubKey', or add an alias to the original parameter name."
Copy link
Member

Choose a reason for hiding this comment

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

You should leave in an alias to ResourceGroup

Copy link
Author

Choose a reason for hiding this comment

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

Removed the exception, alias was added.

"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.Namespace.NewAzureEventHubNamespace","New-AzureRmEventHubNamespace","0","2100","The parameter 'SkuName' in cmdlet 'New-AzureRmEventHubNamespace' is no longer in the parameter set '__AllParameterSets'.","Add parameter 'SkuName' back to the parameter set '__AllParameterSets'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.Namespace.NewAzureEventHubNamespace","New-AzureRmEventHubNamespace","0","2100","The parameter 'SkuCapacity' in cmdlet 'New-AzureRmEventHubNamespace' is no longer in the parameter set '__AllParameterSets'.","Add parameter 'SkuCapacity' back to the parameter set '__AllParameterSets'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.Namespace.NewAzureEventHubNamespace","New-AzureRmEventHubNamespace","0","2100","The parameter 'Tag' in cmdlet 'New-AzureRmEventHubNamespace' is no longer in the parameter set '__AllParameterSets'.","Add parameter 'Tag' back to the parameter set '__AllParameterSets'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.AnalysisServices\Microsoft.Azure.Commands.AnalysisServices.dll","Microsoft.Azure.Commands.AnalysisServices.NewAnalysisServicesServer","New-AzureRmAnalysisServicesServer","0","2060","The position of parameter 'Administrator' has changed for parameter set '__AllParameterSets' for cmdlet 'New-AzureRmAnalysisServicesServer'.","Revert the position change made to parameter 'Administrator' for parameter set '__AllParameterSets'."
Copy link
Member

Choose a reason for hiding this comment

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

not removed

@v-Ajnava
Copy link
Author

v-Ajnava commented Aug 6, 2017

@markcowl , Resolved the comments.

@cormacpayne
Copy link
Member

"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.EventHub.GetAzureRmEventHubAuthorizationRule","Get-AzureRmEventHubAuthorizationRule","0","2100","The parameter 'EventHubName' in cmdlet 'Get-AzureRmEventHubAuthorizationRule' is no longer in the parameter set '__AllParameterSets'.","Add parameter 'EventHubName' back to the parameter set '__AllParameterSets'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.EventHub.GetAzureEventHubKey","Get-AzureRmEventHubKey","0","2100","The parameter 'NamespaceName' in cmdlet 'Get-AzureRmEventHubKey' is no longer in the parameter set '__AllParameterSets'.","Add parameter 'NamespaceName' back to the parameter set '__AllParameterSets'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.EventHub.GetAzureEventHubKey","Get-AzureRmEventHubKey","0","2100","The parameter 'EventHubName' in cmdlet 'Get-AzureRmEventHubKey' is no longer in the parameter set '__AllParameterSets'.","Add parameter 'EventHubName' back to the parameter set '__AllParameterSets'."
"D:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.EventHub\Microsoft.Azure.Commands.EventHub.dll","Microsoft.Azure.Commands.EventHub.Commands.EventHub.NewAzureRmEventHub","New-AzureRmEventHub","0","2060","The position of parameter 'EventHubName' has changed for parameter set '__AllParameterSets' for cmdlet 'New-AzureRmEventHub'.","Revert the position change made to parameter 'EventHubName' for parameter set '__AllParameterSets'."
Copy link
Member

Choose a reason for hiding this comment

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

New-AzureRmEventHub EventHubName position has changed. This is a breaking change. Please change it back

Copy link
Member

Choose a reason for hiding this comment

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

Actually, looks liek this is just stale. Please remove this in a separate PR.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, will raise a separate PR.

@cormacpayne cormacpayne merged commit c09c61c into Azure:release-4.3.0 Aug 7, 2017
@v-Ajnava v-Ajnava deleted the EHpwr2017 branch April 12, 2018 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants