Skip to content

Commit 8bb3743

Browse files
skayaniVeryEarlydramuy
authored
Managed services cmdlet changes (#12105)
* New-AzManagedServicesDefinition changes * Get-AzManagedServicesDefinition changes * Remove-AzManagedServicesDefinition changes * New-AzManagedServicesAssignment changes * Get-AzManagedServicesAssignment changes * Remove-AzManagedServicesAssignment changes * Made consistency changes * Small name fix * Made suggested changes by Ramu * Made changes suggested by Ramu - updated examples * Changed gets to return 'Scope' * Updated ChangeLog.md + added header for newly added file * Fixed spacing issues in Get cmdlet .md files * Update ChangeLog.md * Added missing comment line * Add new parameters for authorizations list and other changes to improve consistency across cmdlets for Azure Lighthouse * Update the unit test to include the breaking change with displayName and parameter bound issues calling through cmdlet execute * Changed Authorizations parameter to Authorization and added PassThru to remove cmdlets * Changed remove cmdlet return types to bool && git push * Suppressed breaking changes for S177 milestone * Changed BreakingChangesIssues.csv -> BreakingChangeIssues.csv * Update ChangeLog.md Co-authored-by: Yabo Hu <[email protected]> Co-authored-by: NORTHAMERICA\dramuy <[email protected]>
1 parent cb57f86 commit 8bb3743

29 files changed

+813
-941
lines changed

src/ManagedServices/ManagedServices.Test/ScenarioTests/ManagedServicesTests.ps1

Lines changed: 49 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -17,140 +17,59 @@
1717
Create, update, and delete registration assignments and registration definitions
1818
#>
1919

20-
function New-AzManagedServicesAssignmentWithId
21-
{
22-
[CmdletBinding()]
23-
param(
24-
[string] [Parameter()] $Scope,
25-
[string] [Parameter()] $RegistrationDefinitionResourceId,
26-
[Guid] [Parameter()] $RegistrationAssignmentId
27-
)
28-
29-
$profile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
30-
$cmdlet = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.ManagedServices.Commands.NewAzureRmManagedServicesAssignment
31-
$cmdlet.DefaultProfile = $profile
32-
$cmdlet.CommandRuntime = $PSCmdlet.CommandRuntime
33-
34-
if (-not ([string]::IsNullOrEmpty($Scope)))
35-
{
36-
$cmdlet.Scope = $Scope
37-
}
38-
39-
if (-not ([string]::IsNullOrEmpty($RegistrationDefinitionResourceId)))
40-
{
41-
$cmdlet.RegistrationDefinitionResourceId = $RegistrationDefinitionResourceId
42-
}
43-
44-
if ($RegistrationAssignmentId -ne $null -and $RegistrationAssignmentId -ne [System.Guid]::Empty)
45-
{
46-
$cmdlet.RegistrationAssignmentId = $RegistrationAssignmentId
47-
}
48-
49-
$cmdlet.ExecuteCmdlet()
50-
}
51-
52-
function New-AzManagedServicesDefinitionWithId
20+
function Test-ManagedServices_CRUD
5321
{
54-
[CmdletBinding()]
55-
param(
56-
[string] [Parameter()] $Name,
57-
[string] [Parameter()] $ManagedByTenantId,
58-
[string] [Parameter()] $PrincipalId,
59-
[string] [Parameter()] $RoleDefinitionId,
60-
[string] [Parameter()] $Description,
61-
[Guid] [Parameter()] $RegistrationDefinitionId
62-
)
63-
64-
$profile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
65-
$cmdlet = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.ManagedServices.Commands.NewAzureRmManagedServicesDefinition
66-
$cmdlet.DefaultProfile = $profile
67-
$cmdlet.CommandRuntime = $PSCmdlet.CommandRuntime
68-
69-
if (-not ([string]::IsNullOrEmpty($Description)))
22+
$roleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7"
23+
$managedByTenantId = "bab3375b-6197-4a15-a44b-16c41faa91d7"
24+
$principalId = "d6f6c88a-5b7a-455e-ba40-ce146d4d3671"
25+
$subscriptionId = "002b3477-bfbf-4402-b377-6003168b75d3"
26+
$displayName = "Resource display name"
27+
$assignmentId = "8af8768c-73c2-4993-86ae-7a45c9b232c6"
28+
$definitionId = "1ccdb215-959a-48b9-bd7c-0584d461ea6c"
29+
30+
#put definition
31+
$definition = New-AzManagedServicesDefinition -ManagedByTenantId $managedByTenantId -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -DisplayName $displayName -Name $definitionId
32+
33+
Assert-AreEqual $definitionId $definition.Name
34+
Assert-AreEqual $displayName $definition.Properties.DisplayName
35+
Assert-AreEqual $managedByTenantId $definition.Properties.ManagedByTenantId
36+
Assert-AreEqual $roleDefinitionId $definition.Properties.Authorization[0].RoleDefinitionId
37+
Assert-AreEqual $principalId $definition.Properties.Authorization[0].PrincipalId
38+
39+
# get definition
40+
$retrievedDefinition = Get-AzManagedServicesDefinition -Name $definitionId
41+
Assert-NotNull $retrievedDefinition
42+
Assert-AreEqual $definition.Id $retrievedDefinition.Id
43+
44+
#put assignment
45+
$assignment = New-AzManagedServicesAssignment `
46+
-RegistrationDefinitionId $definition.Id `
47+
-Name $assignmentId
48+
Assert-NotNull $assignment
49+
50+
#get assignment
51+
$retrievedAssignment = Get-AzManagedServicesAssignment -Name $assignmentId -ExpandRegistrationDefinition
52+
Assert-NotNull $retrievedAssignment
53+
Assert-AreEqual $assignment.Id $retrievedAssignment.Id
54+
Assert-AreEqual $definition.Id $retrievedAssignment.Properties.RegistrationDefinitionId
55+
56+
#remove assignment
57+
Remove-AzManagedServicesAssignment -Name $assignmentId
58+
59+
#remove definition
60+
Remove-AzManagedServicesDefinition -Name $definitionId
61+
62+
#list assignments
63+
$assignments = Get-AzManagedServicesAssignment
64+
Foreach($assignment in $assignments)
7065
{
71-
$cmdlet.Description = $Description
66+
Assert-AreNotEqual($assignmentId, $assignment.Name)
7267
}
7368

74-
if (-not ([string]::IsNullOrEmpty($Name)))
69+
#list definitions
70+
$definitions = Get-AzManagedServicesDefinition
71+
Foreach($definition in $definitions)
7572
{
76-
$cmdlet.Name = $Name
73+
Assert-AreNotEqual($assignmentId, $assignment.Name)
7774
}
78-
79-
if (-not ([string]::IsNullOrEmpty($ManagedByTenantId)))
80-
{
81-
$cmdlet.ManagedByTenantId = $ManagedByTenantId
82-
}
83-
84-
if (-not ([string]::IsNullOrEmpty($PrincipalId)))
85-
{
86-
$cmdlet.PrincipalId = $PrincipalId
87-
}
88-
89-
if (-not ([string]::IsNullOrEmpty($RoleDefinitionId)))
90-
{
91-
$cmdlet.RoleDefinitionId = $RoleDefinitionId
92-
}
93-
94-
if ($RegistrationDefinitionId -ne $null -and $RegistrationDefinitionId -ne [System.Guid]::Empty)
95-
{
96-
$cmdlet.RegistrationDefinitionId = $RegistrationDefinitionId
97-
}
98-
99-
$cmdlet.ExecuteCmdlet()
100-
}
101-
102-
function Test-ManagedServices_CRUD
103-
{
104-
$roleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7";
105-
$managedByTenantId = "bab3375b-6197-4a15-a44b-16c41faa91d7";
106-
$principalId = "d6f6c88a-5b7a-455e-ba40-ce146d4d3671";
107-
$subscriptionId = "002b3477-bfbf-4402-b377-6003168b75d3"
108-
$name = getAssetName
109-
$assignmentId = "8af8768c-73c2-4993-86ae-7a45c9b232c6";
110-
$definitionId = "1ccdb215-959a-48b9-bd7c-0584d461ea6c"
111-
112-
#put def
113-
$definition = New-AzManagedServicesDefinitionWithId -ManagedByTenantId $managedByTenantId -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -Name $name -RegistrationDefinitionId $definitionId
114-
115-
Assert-AreEqual $name $definition.Properties.Name
116-
Assert-AreEqual $managedByTenantId $definition.Properties.ManagedByTenantId
117-
Assert-AreEqual $roleDefinitionId $definition.Properties.Authorization[0].RoleDefinitionId
118-
Assert-AreEqual $principalId $definition.Properties.Authorization[0].PrincipalId
119-
120-
# get def
121-
$getDef = Get-AzManagedServicesDefinition -Name $definitionId
122-
Assert-NotNull $getDef
123-
Assert-AreEqual $definition.Id $getDef.Id
124-
125-
#put assignment
126-
$assignment = New-AzManagedServicesAssignmentWithId `
127-
-RegistrationDefinitionResourceId $definition.Id `
128-
-RegistrationAssignmentId $assignmentId
129-
Assert-NotNull $assignment
130-
131-
#get assignment
132-
$getAssignment = Get-AzManagedServicesAssignment -Id $assignmentId -ExpandRegistrationDefinition
133-
Assert-NotNull $getAssignment
134-
Assert-AreEqual $assignment.Id $getAssignment.Id
135-
Assert-AreEqual $definition.Id $getAssignment.Properties.RegistrationDefinitionId
136-
137-
#remove assignment
138-
Remove-AzManagedServicesAssignment -Id $assignmentId
139-
140-
#remove definition
141-
Remove-AzManagedServicesDefinition -Id $definitionId
142-
143-
#list assignments
144-
$assignments = Get-AzManagedServicesAssignment
145-
Foreach($assignment in $assignments)
146-
{
147-
Assert-AreNotEqual($assignmentId, $assignment.Name)
148-
}
149-
150-
#list definitions
151-
$definitions = Get-AzManagedServicesDefinition
152-
Foreach($definition in $definitions)
153-
{
154-
Assert-AreNotEqual($definitionId, $definition.Name)
155-
}
15675
}

src/ManagedServices/ManagedServices.Test/ScenarioTests/TestController.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System;
16-
using System.Collections.Generic;
17-
using System.Diagnostics;
18-
using System.IO;
19-
using System.Linq;
2015
using Microsoft.Azure.Commands.Common.Authentication;
21-
using Microsoft.Azure.Management.Storage.Version2017_10_01;
16+
using Microsoft.Azure.Management.Internal.Resources;
17+
using Microsoft.Azure.Management.ManagedServices;
2218
using Microsoft.Azure.Test.HttpRecorder;
2319
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
2420
using Microsoft.WindowsAzure.Commands.ScenarioTest;
2521
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
22+
using System;
23+
using System.Collections.Generic;
24+
using System.Diagnostics;
25+
using System.IO;
26+
using System.Linq;
2627
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
27-
using Microsoft.Azure.Management.Internal.Resources;
28-
using Microsoft.Azure.Management.ManagedServices;
2928

3029
namespace Microsoft.Azure.PowerShell.Cmdlets.ManagedServices.Test.ScenarioTests
3130
{

src/ManagedServices/ManagedServices.Test/SessionRecords/Microsoft.Azure.PowerShell.Cmdlets.ManagedServices.Test.ScenarioTests.ManagedServicesTests/ManagedServices_CRUD.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"RequestUri": "//subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c?api-version=2019-06-01",
55
"EncodedRequestUri": "Ly9zdWJzY3JpcHRpb25zLzAwMmIzNDc3LWJmYmYtNDQwMi1iMzc3LTYwMDMxNjhiNzVkMy9wcm92aWRlcnMvTWljcm9zb2Z0Lk1hbmFnZWRTZXJ2aWNlcy9yZWdpc3RyYXRpb25EZWZpbml0aW9ucy8xY2NkYjIxNS05NTlhLTQ4YjktYmQ3Yy0wNTg0ZDQ2MWVhNmM/YXBpLXZlcnNpb249MjAxOS0wNi0wMQ==",
66
"RequestMethod": "PUT",
7-
"RequestBody": "{\r\n \"properties\": {\r\n \"authorizations\": [\r\n {\r\n \"principalId\": \"d6f6c88a-5b7a-455e-ba40-ce146d4d3671\",\r\n \"roleDefinitionId\": \"acdd72a7-3385-48ef-bd42-f606fba81ae7\"\r\n }\r\n ],\r\n \"registrationDefinitionName\": \"ps4125\",\r\n \"managedByTenantId\": \"bab3375b-6197-4a15-a44b-16c41faa91d7\"\r\n }\r\n}",
7+
"RequestBody": "{\r\n \"properties\": {\r\n \"authorizations\": [\r\n {\r\n \"principalId\": \"d6f6c88a-5b7a-455e-ba40-ce146d4d3671\",\r\n \"roleDefinitionId\": \"acdd72a7-3385-48ef-bd42-f606fba81ae7\"\r\n }\r\n ],\r\n \"registrationDefinitionName\": \"Resource display name\",\r\n \"managedByTenantId\": \"bab3375b-6197-4a15-a44b-16c41faa91d7\"\r\n }\r\n}",
88
"RequestHeaders": {
99
"x-ms-client-request-id": [
1010
"d76ebdf0-ae7f-40a3-b5a7-2bd5ce00075a"
@@ -63,7 +63,7 @@
6363
"-1"
6464
]
6565
},
66-
"ResponseBody": "{\r\n \"properties\": {\r\n \"registrationDefinitionName\": \"ps4125\",\r\n \"managedByTenantId\": \"bab3375b-6197-4a15-a44b-16c41faa91d7\",\r\n \"authorizations\": [\r\n {\r\n \"principalId\": \"d6f6c88a-5b7a-455e-ba40-ce146d4d3671\",\r\n \"roleDefinitionId\": \"acdd72a7-3385-48ef-bd42-f606fba81ae7\"\r\n }\r\n ],\r\n \"provisioningState\": \"Succeeded\",\r\n \"managedByTenantName\": \"Default Directory\"\r\n },\r\n \"id\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c\",\r\n \"type\": \"Microsoft.ManagedServices/registrationDefinitions\",\r\n \"name\": \"1ccdb215-959a-48b9-bd7c-0584d461ea6c\"\r\n}",
66+
"ResponseBody": "{\r\n \"properties\": {\r\n \"registrationDefinitionName\": \"Resource display name\",\r\n \"managedByTenantId\": \"bab3375b-6197-4a15-a44b-16c41faa91d7\",\r\n \"authorizations\": [\r\n {\r\n \"principalId\": \"d6f6c88a-5b7a-455e-ba40-ce146d4d3671\",\r\n \"roleDefinitionId\": \"acdd72a7-3385-48ef-bd42-f606fba81ae7\"\r\n }\r\n ],\r\n \"provisioningState\": \"Succeeded\",\r\n \"managedByTenantName\": \"Default Directory\"\r\n },\r\n \"id\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c\",\r\n \"type\": \"Microsoft.ManagedServices/registrationDefinitions\",\r\n \"name\": \"1ccdb215-959a-48b9-bd7c-0584d461ea6c\"\r\n}",
6767
"StatusCode": 201
6868
},
6969
{
@@ -126,7 +126,7 @@
126126
"-1"
127127
]
128128
},
129-
"ResponseBody": "{\r\n \"properties\": {\r\n \"registrationDefinitionName\": \"ps4125\",\r\n \"managedByTenantId\": \"bab3375b-6197-4a15-a44b-16c41faa91d7\",\r\n \"authorizations\": [\r\n {\r\n \"principalId\": \"d6f6c88a-5b7a-455e-ba40-ce146d4d3671\",\r\n \"roleDefinitionId\": \"acdd72a7-3385-48ef-bd42-f606fba81ae7\"\r\n }\r\n ],\r\n \"provisioningState\": \"Succeeded\",\r\n \"managedByTenantName\": \"Default Directory\"\r\n },\r\n \"id\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c\",\r\n \"type\": \"Microsoft.ManagedServices/registrationDefinitions\",\r\n \"name\": \"1ccdb215-959a-48b9-bd7c-0584d461ea6c\"\r\n}",
129+
"ResponseBody": "{\r\n \"properties\": {\r\n \"registrationDefinitionName\": \"Resource display name\",\r\n \"managedByTenantId\": \"bab3375b-6197-4a15-a44b-16c41faa91d7\",\r\n \"authorizations\": [\r\n {\r\n \"principalId\": \"d6f6c88a-5b7a-455e-ba40-ce146d4d3671\",\r\n \"roleDefinitionId\": \"acdd72a7-3385-48ef-bd42-f606fba81ae7\"\r\n }\r\n ],\r\n \"provisioningState\": \"Succeeded\",\r\n \"managedByTenantName\": \"Default Directory\"\r\n },\r\n \"id\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c\",\r\n \"type\": \"Microsoft.ManagedServices/registrationDefinitions\",\r\n \"name\": \"1ccdb215-959a-48b9-bd7c-0584d461ea6c\"\r\n}",
130130
"StatusCode": 200
131131
},
132132
{
@@ -375,7 +375,7 @@
375375
"-1"
376376
]
377377
},
378-
"ResponseBody": "{\r\n \"properties\": {\r\n \"registrationDefinitionId\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"registrationDefinition\": {\r\n \"properties\": {\r\n \"registrationDefinitionName\": \"ps4125\",\r\n \"managedByTenantId\": \"bab3375b-6197-4a15-a44b-16c41faa91d7\",\r\n \"authorizations\": [\r\n {\r\n \"principalId\": \"d6f6c88a-5b7a-455e-ba40-ce146d4d3671\",\r\n \"roleDefinitionId\": \"acdd72a7-3385-48ef-bd42-f606fba81ae7\"\r\n }\r\n ],\r\n \"provisioningState\": \"Succeeded\",\r\n \"manageeTenantId\": \"72f988bf-86f1-41af-91ab-2d7cd011db47\",\r\n \"manageeTenantName\": \"Microsoft\",\r\n \"managedByTenantName\": \"Default Directory\"\r\n },\r\n \"id\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c\",\r\n \"type\": \"Microsoft.ManagedServices/registrationDefinitions\",\r\n \"name\": \"1ccdb215-959a-48b9-bd7c-0584d461ea6c\"\r\n }\r\n },\r\n \"id\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationAssignments/8af8768c-73c2-4993-86ae-7a45c9b232c6\",\r\n \"type\": \"Microsoft.ManagedServices/registrationAssignments\",\r\n \"name\": \"8af8768c-73c2-4993-86ae-7a45c9b232c6\"\r\n}",
378+
"ResponseBody": "{\r\n \"properties\": {\r\n \"registrationDefinitionId\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"registrationDefinition\": {\r\n \"properties\": {\r\n \"registrationDefinitionName\": \"Resource display name\",\r\n \"managedByTenantId\": \"bab3375b-6197-4a15-a44b-16c41faa91d7\",\r\n \"authorizations\": [\r\n {\r\n \"principalId\": \"d6f6c88a-5b7a-455e-ba40-ce146d4d3671\",\r\n \"roleDefinitionId\": \"acdd72a7-3385-48ef-bd42-f606fba81ae7\"\r\n }\r\n ],\r\n \"provisioningState\": \"Succeeded\",\r\n \"manageeTenantId\": \"72f9acbf-86f1-41af-91ab-2d7ef011db47\",\r\n \"manageeTenantName\": \"Microsoft\",\r\n \"managedByTenantName\": \"Default Directory\"\r\n },\r\n \"id\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c\",\r\n \"type\": \"Microsoft.ManagedServices/registrationDefinitions\",\r\n \"name\": \"1ccdb215-959a-48b9-bd7c-0584d461ea6c\"\r\n }\r\n },\r\n \"id\": \"/subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationAssignments/8af8768c-73c2-4993-86ae-7a45c9b232c6\",\r\n \"type\": \"Microsoft.ManagedServices/registrationAssignments\",\r\n \"name\": \"8af8768c-73c2-4993-86ae-7a45c9b232c6\"\r\n}",
379379
"StatusCode": 200
380380
},
381381
{

src/ManagedServices/ManagedServices/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+
* [Breaking Change]Updated parametersnaming conventions and associated examples
2122

2223
## Version 1.1.1
2324
* Updated breaking change warnings on cmdlets of managed services assignment and definition

0 commit comments

Comments
 (0)