Skip to content
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

Managed services cmdlet changes #12105

Merged
merged 25 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
23ae023
New-AzManagedServicesDefinition changes
skayani May 14, 2020
12c0466
Get-AzManagedServicesDefinition changes
skayani May 14, 2020
bc030a4
Remove-AzManagedServicesDefinition changes
skayani May 14, 2020
02a8d8b
New-AzManagedServicesAssignment changes
skayani May 14, 2020
d60a00b
Get-AzManagedServicesAssignment changes
skayani May 15, 2020
200d68c
Remove-AzManagedServicesAssignment changes
skayani May 15, 2020
722d2bb
Made consistency changes
skayani May 15, 2020
8fb2e07
Small name fix
skayani May 15, 2020
27b38eb
Made suggested changes by Ramu
skayani May 15, 2020
c0f21a8
Made changes suggested by Ramu - updated examples
skayani Jun 2, 2020
acb21a9
Changed gets to return 'Scope'
skayani Jun 5, 2020
ec7a927
Updated ChangeLog.md + added header for newly added file
skayani Jun 5, 2020
8d25152
Fixed spacing issues in Get cmdlet .md files
skayani Jun 5, 2020
a75a77e
Update ChangeLog.md
VeryEarly Jun 10, 2020
354650a
Merge remote-tracking branch 'upstream/master' into managedServicesCm…
skayani Aug 24, 2020
64d5805
Added missing comment line
skayani Aug 26, 2020
ff8de39
Add new parameters for authorizations list and other changes to impro…
dramuy Sep 4, 2020
33699b7
Update the unit test to include the breaking change with displayName …
dramuy Sep 9, 2020
f9a8165
Changed Authorizations parameter to Authorization and added PassThru …
skayani Sep 14, 2020
6ff9e3d
Changed remove cmdlet return types to bool && git push
skayani Sep 15, 2020
ce2349f
Merge remote-tracking branch 'upstream/master' into managedServicesCm…
skayani Sep 22, 2020
484678c
Merge branch 'master' into managedServicesCmdletChanges
skayani Oct 9, 2020
3caf919
Suppressed breaking changes for S177 milestone
skayani Oct 13, 2020
c4fbbb1
Changed BreakingChangesIssues.csv -> BreakingChangeIssues.csv
skayani Oct 14, 2020
fbb982b
Update ChangeLog.md
VeryEarly Oct 15, 2020
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 @@ -17,140 +17,59 @@
Create, update, and delete registration assignments and registration definitions
#>

function New-AzManagedServicesAssignmentWithId
{
[CmdletBinding()]
param(
[string] [Parameter()] $Scope,
[string] [Parameter()] $RegistrationDefinitionResourceId,
[Guid] [Parameter()] $RegistrationAssignmentId
)

$profile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$cmdlet = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.ManagedServices.Commands.NewAzureRmManagedServicesAssignment
$cmdlet.DefaultProfile = $profile
$cmdlet.CommandRuntime = $PSCmdlet.CommandRuntime

if (-not ([string]::IsNullOrEmpty($Scope)))
{
$cmdlet.Scope = $Scope
}

if (-not ([string]::IsNullOrEmpty($RegistrationDefinitionResourceId)))
{
$cmdlet.RegistrationDefinitionResourceId = $RegistrationDefinitionResourceId
}

if ($RegistrationAssignmentId -ne $null -and $RegistrationAssignmentId -ne [System.Guid]::Empty)
{
$cmdlet.RegistrationAssignmentId = $RegistrationAssignmentId
}

$cmdlet.ExecuteCmdlet()
}

function New-AzManagedServicesDefinitionWithId
function Test-ManagedServices_CRUD
{
[CmdletBinding()]
param(
[string] [Parameter()] $Name,
[string] [Parameter()] $ManagedByTenantId,
[string] [Parameter()] $PrincipalId,
[string] [Parameter()] $RoleDefinitionId,
[string] [Parameter()] $Description,
[Guid] [Parameter()] $RegistrationDefinitionId
)

$profile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$cmdlet = New-Object -TypeName Microsoft.Azure.PowerShell.Cmdlets.ManagedServices.Commands.NewAzureRmManagedServicesDefinition
$cmdlet.DefaultProfile = $profile
$cmdlet.CommandRuntime = $PSCmdlet.CommandRuntime

if (-not ([string]::IsNullOrEmpty($Description)))
$roleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7"
$managedByTenantId = "bab3375b-6197-4a15-a44b-16c41faa91d7"
$principalId = "d6f6c88a-5b7a-455e-ba40-ce146d4d3671"
$subscriptionId = "002b3477-bfbf-4402-b377-6003168b75d3"
$displayName = "Resource display name"
$assignmentId = "8af8768c-73c2-4993-86ae-7a45c9b232c6"
$definitionId = "1ccdb215-959a-48b9-bd7c-0584d461ea6c"

#put definition
$definition = New-AzManagedServicesDefinition -ManagedByTenantId $managedByTenantId -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -DisplayName $displayName -Name $definitionId

Assert-AreEqual $definitionId $definition.Name
Assert-AreEqual $displayName $definition.Properties.DisplayName
Assert-AreEqual $managedByTenantId $definition.Properties.ManagedByTenantId
Assert-AreEqual $roleDefinitionId $definition.Properties.Authorization[0].RoleDefinitionId
Assert-AreEqual $principalId $definition.Properties.Authorization[0].PrincipalId

# get definition
$retrievedDefinition = Get-AzManagedServicesDefinition -Name $definitionId
Assert-NotNull $retrievedDefinition
Assert-AreEqual $definition.Id $retrievedDefinition.Id

#put assignment
$assignment = New-AzManagedServicesAssignment `
-RegistrationDefinitionId $definition.Id `
-Name $assignmentId
Assert-NotNull $assignment

#get assignment
$retrievedAssignment = Get-AzManagedServicesAssignment -Name $assignmentId -ExpandRegistrationDefinition
Assert-NotNull $retrievedAssignment
Assert-AreEqual $assignment.Id $retrievedAssignment.Id
Assert-AreEqual $definition.Id $retrievedAssignment.Properties.RegistrationDefinitionId

#remove assignment
Remove-AzManagedServicesAssignment -Name $assignmentId

#remove definition
Remove-AzManagedServicesDefinition -Name $definitionId

#list assignments
$assignments = Get-AzManagedServicesAssignment
Foreach($assignment in $assignments)
{
$cmdlet.Description = $Description
Assert-AreNotEqual($assignmentId, $assignment.Name)
}

if (-not ([string]::IsNullOrEmpty($Name)))
#list definitions
$definitions = Get-AzManagedServicesDefinition
Foreach($definition in $definitions)
{
$cmdlet.Name = $Name
Assert-AreNotEqual($assignmentId, $assignment.Name)
}

if (-not ([string]::IsNullOrEmpty($ManagedByTenantId)))
{
$cmdlet.ManagedByTenantId = $ManagedByTenantId
}

if (-not ([string]::IsNullOrEmpty($PrincipalId)))
{
$cmdlet.PrincipalId = $PrincipalId
}

if (-not ([string]::IsNullOrEmpty($RoleDefinitionId)))
{
$cmdlet.RoleDefinitionId = $RoleDefinitionId
}

if ($RegistrationDefinitionId -ne $null -and $RegistrationDefinitionId -ne [System.Guid]::Empty)
{
$cmdlet.RegistrationDefinitionId = $RegistrationDefinitionId
}

$cmdlet.ExecuteCmdlet()
}

function Test-ManagedServices_CRUD
{
$roleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7";
$managedByTenantId = "bab3375b-6197-4a15-a44b-16c41faa91d7";
$principalId = "d6f6c88a-5b7a-455e-ba40-ce146d4d3671";
$subscriptionId = "002b3477-bfbf-4402-b377-6003168b75d3"
$name = getAssetName
$assignmentId = "8af8768c-73c2-4993-86ae-7a45c9b232c6";
$definitionId = "1ccdb215-959a-48b9-bd7c-0584d461ea6c"

#put def
$definition = New-AzManagedServicesDefinitionWithId -ManagedByTenantId $managedByTenantId -RoleDefinitionId $roleDefinitionId -PrincipalId $principalId -Name $name -RegistrationDefinitionId $definitionId

Assert-AreEqual $name $definition.Properties.Name
Assert-AreEqual $managedByTenantId $definition.Properties.ManagedByTenantId
Assert-AreEqual $roleDefinitionId $definition.Properties.Authorization[0].RoleDefinitionId
Assert-AreEqual $principalId $definition.Properties.Authorization[0].PrincipalId

# get def
$getDef = Get-AzManagedServicesDefinition -Name $definitionId
Assert-NotNull $getDef
Assert-AreEqual $definition.Id $getDef.Id

#put assignment
$assignment = New-AzManagedServicesAssignmentWithId `
-RegistrationDefinitionResourceId $definition.Id `
-RegistrationAssignmentId $assignmentId
Assert-NotNull $assignment

#get assignment
$getAssignment = Get-AzManagedServicesAssignment -Id $assignmentId -ExpandRegistrationDefinition
Assert-NotNull $getAssignment
Assert-AreEqual $assignment.Id $getAssignment.Id
Assert-AreEqual $definition.Id $getAssignment.Properties.RegistrationDefinitionId

#remove assignment
Remove-AzManagedServicesAssignment -Id $assignmentId

#remove definition
Remove-AzManagedServicesDefinition -Id $definitionId

#list assignments
$assignments = Get-AzManagedServicesAssignment
Foreach($assignment in $assignments)
{
Assert-AreNotEqual($assignmentId, $assignment.Name)
}

#list definitions
$definitions = Get-AzManagedServicesDefinition
Foreach($definition in $definitions)
{
Assert-AreNotEqual($definitionId, $definition.Name)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Management.Storage.Version2017_10_01;
using Microsoft.Azure.Management.Internal.Resources;
using Microsoft.Azure.Management.ManagedServices;
using Microsoft.Azure.Test.HttpRecorder;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory;
using Microsoft.Azure.Management.Internal.Resources;
using Microsoft.Azure.Management.ManagedServices;

namespace Microsoft.Azure.PowerShell.Cmdlets.ManagedServices.Test.ScenarioTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"RequestUri": "//subscriptions/002b3477-bfbf-4402-b377-6003168b75d3/providers/Microsoft.ManagedServices/registrationDefinitions/1ccdb215-959a-48b9-bd7c-0584d461ea6c?api-version=2019-06-01",
"EncodedRequestUri": "Ly9zdWJzY3JpcHRpb25zLzAwMmIzNDc3LWJmYmYtNDQwMi1iMzc3LTYwMDMxNjhiNzVkMy9wcm92aWRlcnMvTWljcm9zb2Z0Lk1hbmFnZWRTZXJ2aWNlcy9yZWdpc3RyYXRpb25EZWZpbml0aW9ucy8xY2NkYjIxNS05NTlhLTQ4YjktYmQ3Yy0wNTg0ZDQ2MWVhNmM/YXBpLXZlcnNpb249MjAxOS0wNi0wMQ==",
"RequestMethod": "PUT",
"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}",
"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}",
"RequestHeaders": {
"x-ms-client-request-id": [
"d76ebdf0-ae7f-40a3-b5a7-2bd5ce00075a"
Expand Down Expand Up @@ -63,7 +63,7 @@
"-1"
]
},
"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}",
"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}",
"StatusCode": 201
},
{
Expand Down Expand Up @@ -126,7 +126,7 @@
"-1"
]
},
"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}",
"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}",
"StatusCode": 200
},
{
Expand Down Expand Up @@ -375,7 +375,7 @@
"-1"
]
},
"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}",
"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}",
"StatusCode": 200
},
{
Expand Down
1 change: 1 addition & 0 deletions src/ManagedServices/ManagedServices/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* [Breaking Change]Updated parametersnaming conventions and associated examples

## Version 1.1.1
* Updated breaking change warnings on cmdlets of managed services assignment and definition
Expand Down
Loading