Skip to content

Service Bus : updated Set-AzureRmServiceBusRule for the fix of issue - 7161 #7204

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 5 commits into from
Sep 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ function ServiceBusRuleTests
Assert-AreEqual $resultGetSub.Name $subName "Get-Sub, Created Subscription not found"

# Create Rule
$createRule = New-AzureRmServiceBusRule -ResourceGroupName $resourceGroupName -Namespace $namespaceName -Topic $resultGetTopic.Name -Subscription $subName -Name $ruleName -SqlExpression "myproperty='test'"
$createRule = New-AzureRmServiceBusRule -ResourceGroupName $resourceGroupName -Namespace $namespaceName -Topic $resultGetTopic.Name -Subscription $subName -Name $ruleName -SqlExpression "myproperty='test'" -ActionSqlExpression "SET myAction='test'" -RequiresPreprocessing
Assert-AreEqual $createRule.Name $ruleName "Rule created earlier is not found."
Assert-AreEqual $createRule.Action.SqlExpression "SET myAction='test'" "Action SqlExpression is not found."

# Get Rule
$getRule = Get-AzureRmServiceBusRule -ResourceGroupName $resourceGroupName -Namespace $namespaceName -Topic $resultGetTopic.Name -Subscription $subName -Name $ruleName
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
- Additional information about change #1
-->
## Current Release
* Fixed issue
- https://github.com/Azure/azure-powershell/issues/7161

## Version 0.6.11
* Fixed issues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public abstract class AzureServiceBusCmdletBase : AzureRMCmdlet
protected const string GeoDRParameterSet = "GeoDRPropertiesSet";
protected const string MigrationConfigurationParameterSet = "MigrationConfigurationPropertiesSet";
protected const string RuleResourceParameterSet = "RulePropertiesSet";
protected const string RuleResourceActionParameterSet = "RuleActionPropertiesSet";

//Alias - used in Cmdlets
protected const string AliasResourceGroupname = "ResourceGroupName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace Microsoft.Azure.Commands.ServiceBus.Commands.Rule
/// <summary>
/// 'New-AzureRmServiceBusRule' Cmdlet creates a new Rule
/// </summary>
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ServiceBusRule", SupportsShouldProcess = true), OutputType(typeof(PSRulesAttributes))]
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ServiceBusRule", DefaultParameterSetName = RuleResourceParameterSet, SupportsShouldProcess = true), OutputType(typeof(PSRulesAttributes))]
public class NewAzureRmServiceBusRule : AzureServiceBusCmdletBase
{
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 0, HelpMessage = "The name of the resource group")]
Expand Down Expand Up @@ -51,20 +51,30 @@ public class NewAzureRmServiceBusRule : AzureServiceBusCmdletBase
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(Mandatory = true,
ValueFromPipelineByPropertyName = true,
Position = 5,
HelpMessage = "Sql Fillter Expression")]
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 5, HelpMessage = "Sql Fillter Expression")]
[ValidateNotNullOrEmpty]
public string SqlExpression { get; set; }

[Parameter(Mandatory = true, ParameterSetName = RuleResourceActionParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Action SqlFillter Expression")]
[ValidateNotNullOrEmpty]
public string ActionSqlExpression { get; set; }

[Parameter(Mandatory = false, ParameterSetName = RuleResourceActionParameterSet, HelpMessage = "Action Requires Preprocessing")]
public SwitchParameter RequiresPreprocessing { get; set; }

public override void ExecuteCmdlet()
{
PSRulesAttributes ruleAttributes = new PSRulesAttributes();

if (!string.IsNullOrEmpty(SqlExpression))
ruleAttributes.SqlFilter.SqlExpression = SqlExpression;

if (!string.IsNullOrEmpty(ActionSqlExpression))
ruleAttributes.Action.SqlExpression = ActionSqlExpression;

if (RequiresPreprocessing.IsPresent)
ruleAttributes.Action.RequiresPreprocessing = true;

if (ShouldProcess(target: Name, action: string.Format(Resources.CreateRule, Name, Topic,Namespace)))
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ public PSRulesAttributes CreateUpdateRules(string resourceGroupName, string name
parameters.Action = new Management.ServiceBus.Models.Action()
{
SqlExpression = ruleAttributes.Action.SqlExpression,
CompatibilityLevel = ruleAttributes.Action.CompatibilityLevel
CompatibilityLevel = ruleAttributes.Action.CompatibilityLevel,
RequiresPreprocessing = ruleAttributes.Action.RequiresPreprocessing
};

if (ruleAttributes.FilterType.ToString().Equals("SqlFilter"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,20 @@ Creates a new rule for a given Subscription of Topic.

## SYNTAX

### RulePropertiesSet (Default)
```
New-AzureRmServiceBusRule [-ResourceGroupName] <String> [-Namespace] <String> [-Topic] <String>
[-Subscription] <String> [-Name] <String> [-SqlExpression] <String> [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
```

### RuleActionPropertiesSet
```
New-AzureRmServiceBusRule [-ResourceGroupName] <String> [-Namespace] <String> [-Topic] <String>
[-Subscription] <String> [-Name] <String> [-SqlExpression] <String> -ActionSqlExpression <String>
[-RequiresPreprocessing] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
The **New-AzureRmServiceBusRule** cmdlet Creates a new rule for given subscription.

Expand All @@ -30,10 +38,33 @@ PS C:\> New-AzureRmServiceBusRule -ResourceGroup Default-ServiceBus-WestUS -Name

The New-AzureRmServiceBusRule cmdlet creates a new rule for the specified Subscription.


### Example 2
```
PS C:\> New-AzureRmServiceBusRule -ResourceGroup Default-ServiceBus-WestUS -Namespace SBExample1 -Topic SBTopic -Subscription SBSubscription -Name SBRule -SqlExpression "mysqlexpression='test'" -ActionSqlExpression "SET myAction='test'" -RequiresPreprocessing
```

The New-AzureRmServiceBusRule cmdlet creates a new rule for the specified Subscription with ActionFilter.

## PARAMETERS

### -ActionSqlExpression
Action SqlFillter Expression

```yaml
Type: System.String
Parameter Sets: RuleActionPropertiesSet
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
The credentials, account, tenant, and subscription used for communication with Azure.

```yaml
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
Expand Down Expand Up @@ -63,7 +94,7 @@ Accept wildcard characters: False
```

### -Namespace
Namespace Name.
Namespace Name

```yaml
Type: System.String
Expand All @@ -77,6 +108,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -RequiresPreprocessing
Action Requires Preprocessing

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: RuleActionPropertiesSet
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ResourceGroupName
The name of the resource group

Expand Down Expand Up @@ -123,7 +169,7 @@ Accept wildcard characters: False
```

### -Topic
Topic Name.
Topic Name

```yaml
Type: System.String
Expand Down Expand Up @@ -169,16 +215,19 @@ Accept wildcard characters: False
```

### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### System.String


## OUTPUTS

### Microsoft.Azure.Commands.ServiceBus.Models.PSRulesAttributes


## NOTES

## RELATED LINKS
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@
"C:\azure-powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.ServiceBus\Microsoft.Azure.Commands.ServiceBus.dll","Microsoft.Azure.Commands.ServiceBus.Commands.Namespace.RemoveAzureRmServiceBusNamespace","Remove-AzureRmServiceBusNamespace","1","8600","Cmdlet 'Remove-AzureRmServiceBusNamespace' has no defined output type.","Add an OutputType attribute that declares the type of the object(s) returned by this cmdlet. If this cmdlet returns no output, please set the output type to 'bool' and make sure to implement the 'PassThru' parameter."
"D:\AzPwrSB\azure-powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.ServiceBus\Microsoft.Azure.Commands.ServiceBus.dll","Microsoft.Azure.Commands.ServiceBus.Commands.Rule.RemoveAzureRmServiceBusRule","Remove-AzureRmServiceBusRule","1","8420","Parameter set 'RulePropertiesSet' of cmdlet 'Remove-AzureRmServiceBusRule' contains at least one parameter with a position larger than four, which is discouraged.","Limit the number of positional parameters in a single parameter set to four or fewer."
"D:\AzPwrSB\azure-powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.ServiceBus\Microsoft.Azure.Commands.ServiceBus.dll","Microsoft.Azure.Commands.ServiceBus.Commands.Rule.RemoveAzureRmServiceBusRule","Remove-AzureRmServiceBusRule","1","8420","Parameter set 'RulePropertiesSet' of cmdlet 'Remove-AzureRmServiceBusRule' contains at least one parameter with a position larger than four, which is discouraged.","Limit the number of positional parameters in a single parameter set to four or fewer."
"c:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.ServiceBus\Microsoft.Azure.Commands.ServiceBus.dll","Microsoft.Azure.Commands.ServiceBus.Commands.Rule.NewAzureRmServiceBusRule","New-AzureRmServiceBusRule","1","8420","Parameter set 'RuleActionPropertiesSet' of cmdlet 'New-AzureRmServiceBusRule' contains at least one parameter with a position larger than four, which is discouraged.","Limit the number of positional parameters in a single parameter set to four or fewer."

Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@
"C:\azure-powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.ServiceBus\Microsoft.Azure.Commands.ServiceBus.dll","Microsoft.Azure.Commands.ServiceBus.Commands.Namespace.RemoveAzureRmServiceBusNamespace","Remove-AzureRmServiceBusNamespace","1","8600","Cmdlet 'Remove-AzureRmServiceBusNamespace' has no defined output type.","Add an OutputType attribute that declares the type of the object(s) returned by this cmdlet. If this cmdlet returns no output, please set the output type to 'bool' and make sure to implement the 'PassThru' parameter."
"D:\AzPwrSB\azure-powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.ServiceBus\Microsoft.Azure.Commands.ServiceBus.dll","Microsoft.Azure.Commands.ServiceBus.Commands.Rule.RemoveAzureRmServiceBusRule","Remove-AzureRmServiceBusRule","1","8420","Parameter set 'RulePropertiesSet' of cmdlet 'Remove-AzureRmServiceBusRule' contains at least one parameter with a position larger than four, which is discouraged.","Limit the number of positional parameters in a single parameter set to four or fewer."
"D:\AzPwrSB\azure-powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.ServiceBus\Microsoft.Azure.Commands.ServiceBus.dll","Microsoft.Azure.Commands.ServiceBus.Commands.Rule.RemoveAzureRmServiceBusRule","Remove-AzureRmServiceBusRule","1","8420","Parameter set 'RulePropertiesSet' of cmdlet 'Remove-AzureRmServiceBusRule' contains at least one parameter with a position larger than four, which is discouraged.","Limit the number of positional parameters in a single parameter set to four or fewer."
"c:\workspace\powershell\src\Package\Debug\ResourceManager\AzureResourceManager\AzureRM.ServiceBus\Microsoft.Azure.Commands.ServiceBus.dll","Microsoft.Azure.Commands.ServiceBus.Commands.Rule.NewAzureRmServiceBusRule","New-AzureRmServiceBusRule","1","8420","Parameter set 'RuleActionPropertiesSet' of cmdlet 'New-AzureRmServiceBusRule' contains at least one parameter with a position larger than four, which is discouraged.","Limit the number of positional parameters in a single parameter set to four or fewer."