Skip to content

Commit 593705f

Browse files
author
Maddie Clayton
authored
Merge pull request #7204 from v-Ajnava/sbrulesaction
Service Bus : updated Set-AzureRmServiceBusRule for the fix of issue - 7161
2 parents d64881c + 065bb47 commit 593705f

File tree

9 files changed

+360
-293
lines changed

9 files changed

+360
-293
lines changed

src/ResourceManager/ServiceBus/Commands.ServiceBus.Test/ScenarioTests/ServiceBusRuleTests.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ function ServiceBusRuleTests
6868
Assert-AreEqual $resultGetSub.Name $subName "Get-Sub, Created Subscription not found"
6969

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

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

src/ResourceManager/ServiceBus/Commands.ServiceBus.Test/SessionRecords/Microsoft.Azure.Commands.ServiceBus.Test.ScenarioTests.ServiceBusRuleTests/ServiceBusRule_CURD.json

Lines changed: 282 additions & 282 deletions
Large diffs are not rendered by default.

src/ResourceManager/ServiceBus/Commands.ServiceBus/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
- Additional information about change #1
2020
-->
2121
## Current Release
22+
* Fixed issue
23+
- https://github.com/Azure/azure-powershell/issues/7161
2224

2325
## Version 0.6.11
2426
* Fixed issues

src/ResourceManager/ServiceBus/Commands.ServiceBus/Cmdlets/AzureServiceBusCmdletBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public abstract class AzureServiceBusCmdletBase : AzureRMCmdlet
9393
protected const string GeoDRParameterSet = "GeoDRPropertiesSet";
9494
protected const string MigrationConfigurationParameterSet = "MigrationConfigurationPropertiesSet";
9595
protected const string RuleResourceParameterSet = "RulePropertiesSet";
96+
protected const string RuleResourceActionParameterSet = "RuleActionPropertiesSet";
9697

9798
//Alias - used in Cmdlets
9899
protected const string AliasResourceGroupname = "ResourceGroupName";

src/ResourceManager/ServiceBus/Commands.ServiceBus/Cmdlets/Rule/NewAzureServiceBusRule.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Microsoft.Azure.Commands.ServiceBus.Commands.Rule
2323
/// <summary>
2424
/// 'New-AzureRmServiceBusRule' Cmdlet creates a new Rule
2525
/// </summary>
26-
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ServiceBusRule", SupportsShouldProcess = true), OutputType(typeof(PSRulesAttributes))]
26+
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ServiceBusRule", DefaultParameterSetName = RuleResourceParameterSet, SupportsShouldProcess = true), OutputType(typeof(PSRulesAttributes))]
2727
public class NewAzureRmServiceBusRule : AzureServiceBusCmdletBase
2828
{
2929
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 0, HelpMessage = "The name of the resource group")]
@@ -51,20 +51,30 @@ public class NewAzureRmServiceBusRule : AzureServiceBusCmdletBase
5151
[ValidateNotNullOrEmpty]
5252
public string Name { get; set; }
5353

54-
[Parameter(Mandatory = true,
55-
ValueFromPipelineByPropertyName = true,
56-
Position = 5,
57-
HelpMessage = "Sql Fillter Expression")]
54+
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, Position = 5, HelpMessage = "Sql Fillter Expression")]
5855
[ValidateNotNullOrEmpty]
5956
public string SqlExpression { get; set; }
6057

58+
[Parameter(Mandatory = true, ParameterSetName = RuleResourceActionParameterSet, ValueFromPipelineByPropertyName = true, HelpMessage = "Action SqlFillter Expression")]
59+
[ValidateNotNullOrEmpty]
60+
public string ActionSqlExpression { get; set; }
61+
62+
[Parameter(Mandatory = false, ParameterSetName = RuleResourceActionParameterSet, HelpMessage = "Action Requires Preprocessing")]
63+
public SwitchParameter RequiresPreprocessing { get; set; }
64+
6165
public override void ExecuteCmdlet()
6266
{
6367
PSRulesAttributes ruleAttributes = new PSRulesAttributes();
6468

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

72+
if (!string.IsNullOrEmpty(ActionSqlExpression))
73+
ruleAttributes.Action.SqlExpression = ActionSqlExpression;
74+
75+
if (RequiresPreprocessing.IsPresent)
76+
ruleAttributes.Action.RequiresPreprocessing = true;
77+
6878
if (ShouldProcess(target: Name, action: string.Format(Resources.CreateRule, Name, Topic,Namespace)))
6979
{
7080
try

src/ResourceManager/ServiceBus/Commands.ServiceBus/Utilities/ServiceBusClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,8 @@ public PSRulesAttributes CreateUpdateRules(string resourceGroupName, string name
601601
parameters.Action = new Management.ServiceBus.Models.Action()
602602
{
603603
SqlExpression = ruleAttributes.Action.SqlExpression,
604-
CompatibilityLevel = ruleAttributes.Action.CompatibilityLevel
604+
CompatibilityLevel = ruleAttributes.Action.CompatibilityLevel,
605+
RequiresPreprocessing = ruleAttributes.Action.RequiresPreprocessing
605606
};
606607

607608
if (ruleAttributes.FilterType.ToString().Equals("SqlFilter"))

src/ResourceManager/ServiceBus/Commands.ServiceBus/help/New-AzureRmServiceBusRule.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@ Creates a new rule for a given Subscription of Topic.
1212

1313
## SYNTAX
1414

15+
### RulePropertiesSet (Default)
1516
```
1617
New-AzureRmServiceBusRule [-ResourceGroupName] <String> [-Namespace] <String> [-Topic] <String>
1718
[-Subscription] <String> [-Name] <String> [-SqlExpression] <String> [-DefaultProfile <IAzureContextContainer>]
1819
[-WhatIf] [-Confirm] [<CommonParameters>]
1920
```
2021

22+
### RuleActionPropertiesSet
23+
```
24+
New-AzureRmServiceBusRule [-ResourceGroupName] <String> [-Namespace] <String> [-Topic] <String>
25+
[-Subscription] <String> [-Name] <String> [-SqlExpression] <String> -ActionSqlExpression <String>
26+
[-RequiresPreprocessing] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
27+
```
28+
2129
## DESCRIPTION
2230
The **New-AzureRmServiceBusRule** cmdlet Creates a new rule for given subscription.
2331

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

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

41+
42+
### Example 2
43+
```
44+
PS C:\> New-AzureRmServiceBusRule -ResourceGroup Default-ServiceBus-WestUS -Namespace SBExample1 -Topic SBTopic -Subscription SBSubscription -Name SBRule -SqlExpression "mysqlexpression='test'" -ActionSqlExpression "SET myAction='test'" -RequiresPreprocessing
45+
```
46+
47+
The New-AzureRmServiceBusRule cmdlet creates a new rule for the specified Subscription with ActionFilter.
48+
3349
## PARAMETERS
3450

51+
### -ActionSqlExpression
52+
Action SqlFillter Expression
53+
54+
```yaml
55+
Type: System.String
56+
Parameter Sets: RuleActionPropertiesSet
57+
Aliases:
58+
59+
Required: True
60+
Position: Named
61+
Default value: None
62+
Accept pipeline input: True (ByPropertyName)
63+
Accept wildcard characters: False
64+
```
65+
3566
### -DefaultProfile
36-
The credentials, account, tenant, and subscription used for communication with azure.
67+
The credentials, account, tenant, and subscription used for communication with Azure.
3768
3869
```yaml
3970
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer
@@ -63,7 +94,7 @@ Accept wildcard characters: False
6394
```
6495
6596
### -Namespace
66-
Namespace Name.
97+
Namespace Name
6798
6899
```yaml
69100
Type: System.String
@@ -77,6 +108,21 @@ Accept pipeline input: True (ByPropertyName)
77108
Accept wildcard characters: False
78109
```
79110
111+
### -RequiresPreprocessing
112+
Action Requires Preprocessing
113+
114+
```yaml
115+
Type: System.Management.Automation.SwitchParameter
116+
Parameter Sets: RuleActionPropertiesSet
117+
Aliases:
118+
119+
Required: False
120+
Position: Named
121+
Default value: None
122+
Accept pipeline input: False
123+
Accept wildcard characters: False
124+
```
125+
80126
### -ResourceGroupName
81127
The name of the resource group
82128
@@ -123,7 +169,7 @@ Accept wildcard characters: False
123169
```
124170
125171
### -Topic
126-
Topic Name.
172+
Topic Name
127173
128174
```yaml
129175
Type: System.String
@@ -169,16 +215,19 @@ Accept wildcard characters: False
169215
```
170216
171217
### CommonParameters
172-
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).
218+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
219+
For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
173220
174221
## INPUTS
175222
176223
### System.String
177224
225+
178226
## OUTPUTS
179227
180228
### Microsoft.Azure.Commands.ServiceBus.Models.PSRulesAttributes
181229
230+
182231
## NOTES
183232
184233
## RELATED LINKS

tools/StaticAnalysis/Exceptions/Az.ServiceBus/SignatureIssues.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@
2525
"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."
2626
"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."
2727
"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."
28+
"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."
29+

tools/StaticAnalysis/Exceptions/AzureRM.ServiceBus/SignatureIssues.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
"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."
2626
"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."
2727
"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."
28+
"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."

0 commit comments

Comments
 (0)