Skip to content

Commit 78b2f9e

Browse files
authored
Merge pull request Azure#9968 from Willem-J-an/master
New-AzRoleAssignment ParameterSet changes to allow parameter Scope as optional
2 parents b6dab3b + 7617492 commit 78b2f9e

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

src/Resources/Resources/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Fix bug where New-AzRoleAssignment could not be called without parameter Scope.
2122

2223
## Version 1.6.2
2324
* Add support for new api version 2019-05-10 for Microsoft.Resource

src/Resources/Resources/RoleAssignments/NewAzureRoleAssignmentCommand.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public class NewAzureRoleAssignmentCommand : ResourcesBaseCmdlet
3232
HelpMessage = "The user or group object id.")]
3333
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ResourceWithObjectId,
3434
HelpMessage = "The user or group object id.")]
35-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ScopeWithObjectId,
36-
HelpMessage = "The user or group object id.")]
3735
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.Empty,
3836
HelpMessage = "The user or group object id.")]
3937
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.RoleIdWithScopeAndObjectId,
@@ -105,9 +103,7 @@ public class NewAzureRoleAssignmentCommand : ResourcesBaseCmdlet
105103
[ValidateNotNullOrEmpty]
106104
public string ParentResource { get; set; }
107105

108-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.Empty,
109-
HelpMessage = "Scope of the role assignment. In the format of relative URI. If not specified, will assign the role at subscription level. If specified, it can either start with \"/subscriptions/<id>\" or the part after that. If it's latter, the current subscription id will be used.")]
110-
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ScopeWithObjectId,
106+
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.Empty,
111107
HelpMessage = "Scope of the role assignment. In the format of relative URI. If not specified, will assign the role at subscription level. If specified, it can either start with \"/subscriptions/<id>\" or the part after that. If it's latter, the current subscription id will be used.")]
112108
[Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ScopeWithSignInName,
113109
HelpMessage = "Scope of the role assignment. In the format of relative URI. If not specified, will assign the role at subscription level. If specified, it can either start with \"/subscriptions/<id>\" or the part after that. If it's latter, the current subscription id will be used.")]
@@ -120,8 +116,6 @@ public class NewAzureRoleAssignmentCommand : ResourcesBaseCmdlet
120116

121117
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.Empty,
122118
HelpMessage = "Role name to assign the principals with.")]
123-
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ScopeWithObjectId,
124-
HelpMessage = "Role name to assign the principals with.")]
125119
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ScopeWithSignInName,
126120
HelpMessage = "Role name to assign the principals with.")]
127121
[Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ScopeWithSPN,

src/Resources/Resources/help/New-AzRoleAssignment.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Assigns the specified RBAC role to the specified principal, at the specified sco
1515

1616
### EmptyParameterSet (Default)
1717
```
18-
New-AzRoleAssignment -ObjectId <String> -Scope <String> -RoleDefinitionName <String> [-AllowDelegation]
18+
New-AzRoleAssignment -ObjectId <String> [-Scope <String>] -RoleDefinitionName <String> [-AllowDelegation]
1919
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
2020
```
2121

@@ -32,12 +32,6 @@ New-AzRoleAssignment -ObjectId <String> -ResourceGroupName <String> -ResourceNam
3232
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
3333
```
3434

35-
### ScopeWithObjectIdParameterSet
36-
```
37-
New-AzRoleAssignment -ObjectId <String> [-Scope <String>] -RoleDefinitionName <String> [-AllowDelegation]
38-
[-DefaultProfile <IAzureContextContainer>] [<CommonParameters>]
39-
```
40-
4135
### RoleIdWithScopeAndObjectIdParameterSet
4236
```
4337
New-AzRoleAssignment -ObjectId <String> -Scope <String> -RoleDefinitionId <Guid> [-AllowDelegation]
@@ -198,7 +192,7 @@ Azure AD Objectid of the user, group or service principal.
198192
199193
```yaml
200194
Type: System.String
201-
Parameter Sets: EmptyParameterSet, ResourceGroupWithObjectIdParameterSet, ResourceWithObjectIdParameterSet, ScopeWithObjectIdParameterSet, RoleIdWithScopeAndObjectIdParameterSet
195+
Parameter Sets: EmptyParameterSet, ResourceGroupWithObjectIdParameterSet, ResourceWithObjectIdParameterSet, RoleIdWithScopeAndObjectIdParameterSet
202196
Aliases: Id, PrincipalId
203197

204198
Required: True
@@ -298,7 +292,7 @@ Reader, Contributor, Virtual Network Administrator, etc.
298292
299293
```yaml
300294
Type: System.String
301-
Parameter Sets: EmptyParameterSet, ResourceGroupWithObjectIdParameterSet, ResourceWithObjectIdParameterSet, ScopeWithObjectIdParameterSet, ResourceGroupWithSignInNameParameterSet, ResourceWithSignInNameParameterSet, ScopeWithSignInNameParameterSet, ResourceGroupWithSPNParameterSet, ResourceWithSPNParameterSet, ScopeWithSPNParameterSet
295+
Parameter Sets: EmptyParameterSet, ResourceGroupWithObjectIdParameterSet, ResourceWithObjectIdParameterSet, ResourceGroupWithSignInNameParameterSet, ResourceWithSignInNameParameterSet, ScopeWithSignInNameParameterSet, ResourceGroupWithSPNParameterSet, ResourceWithSPNParameterSet, ScopeWithSPNParameterSet
302296
Aliases:
303297

304298
Required: True
@@ -318,10 +312,10 @@ If specified, it should start with "/subscriptions/{id}".
318312
319313
```yaml
320314
Type: System.String
321-
Parameter Sets: EmptyParameterSet, RoleIdWithScopeAndObjectIdParameterSet
315+
Parameter Sets: EmptyParameterSet, ScopeWithSignInNameParameterSet, ScopeWithSPNParameterSet
322316
Aliases:
323317

324-
Required: True
318+
Required: False
325319
Position: Named
326320
Default value: None
327321
Accept pipeline input: True (ByPropertyName)
@@ -330,10 +324,10 @@ Accept wildcard characters: False
330324
331325
```yaml
332326
Type: System.String
333-
Parameter Sets: ScopeWithObjectIdParameterSet, ScopeWithSignInNameParameterSet, ScopeWithSPNParameterSet
327+
Parameter Sets: RoleIdWithScopeAndObjectIdParameterSet
334328
Aliases:
335329

336-
Required: False
330+
Required: True
337331
Position: Named
338332
Default value: None
339333
Accept pipeline input: True (ByPropertyName)
@@ -356,7 +350,7 @@ Accept wildcard characters: False
356350
```
357351
358352
### CommonParameters
359-
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).
353+
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).
360354
361355
## INPUTS
362356

0 commit comments

Comments
 (0)