Skip to content
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
3 changes: 1 addition & 2 deletions .github/workflows/ms.management.managementgroups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ jobs:
- name: 'Using test file [${{ matrix.moduleTestFilePaths }}]'
uses: ./.github/actions/templates/validateModuleDeployment
with:
templateFilePath: '${{ env.modulePath }}/deploy.bicep'
parameterFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}'
templateFilePath: '${{ env.modulePath }}/${{ matrix.moduleTestFilePaths }}'
location: '${{ env.location }}'
resourceGroupName: '${{ env.resourceGroupName }}'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
targetScope = 'managementGroup'

// ========== //
// Parameters //
// ========== //
@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.')
param serviceShort string = 'mmgcom'

// ============== //
// Test Execution //
// ============== //

module testDeployment '../../deploy.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
name: '<<namePrefix>>${serviceShort}001'
displayName: 'Test MG'
parentId: last(split(managementGroup().id, '/'))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
targetScope = 'managementGroup'

// ========== //
// Parameters //
// ========== //
@description('Optional. A short identifier for the kind of deployment. Should be kept short to not run into resource-name length-constraints.')
param serviceShort string = 'mmgmin'

// ============== //
// Test Execution //
// ============== //

module testDeployment '../../deploy.bicep' = {
name: '${uniqueString(deployment().name)}-test-${serviceShort}'
params: {
name: '<<namePrefix>>${serviceShort}001'
}
}

This file was deleted.

11 changes: 8 additions & 3 deletions modules/Microsoft.Management/managementGroups/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ param name string
param displayName string = ''

@description('Optional. The management group parent ID. Defaults to current scope.')
param parentId string = ''
param parentId string = last(split(az.managementGroup().id, '/'))

@sys.description('Optional. Location deployment metadata.')
@description('Optional. Location deployment metadata.')
param location string = deployment().location

@description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).')
Expand All @@ -28,14 +28,19 @@ resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (ena
}
}

resource parentManagementGroup 'Microsoft.Management/managementGroups@2021-04-01' existing = {
name: parentId
Comment thread
eriqua marked this conversation as resolved.
scope: tenant()
}

resource managementGroup 'Microsoft.Management/managementGroups@2021-04-01' = {
name: name
scope: tenant()
properties: {
displayName: displayName
details: !empty(parentId) ? {
parent: {
id: '/providers/Microsoft.Management/managementGroups/${parentId}'
id: parentManagementGroup.id
}
} : null
}
Expand Down
51 changes: 44 additions & 7 deletions modules/Microsoft.Management/managementGroups/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ This module has some known **limitations**:
| `displayName` | string | `''` | The friendly name of the management group. If no value is passed then this field will be set to the group ID. |
| `enableDefaultTelemetry` | bool | `True` | Enable telemetry via the Customer Usage Attribution ID (GUID). |
| `location` | string | `[deployment().location]` | Location deployment metadata. |
| `parentId` | string | `''` | The management group parent ID. Defaults to current scope. |
| `parentId` | string | `[last(split(managementGroup().id, '/'))]` | The management group parent ID. Defaults to current scope. |


### Parameter Usage: `roleAssignments`
Expand Down Expand Up @@ -133,21 +133,21 @@ The following module usage examples are retrieved from the content of the files

>**Note**: Each example lists all the required parameters first, followed by the rest - each in alphabetical order.

<h3>Example 1: Parameters</h3>
<h3>Example 1: Common</h3>

<details>

<summary>via Bicep module</summary>

```bicep
module managementGroups './Microsoft.Management/managementGroups/deploy.bicep' = {
name: '${uniqueString(deployment().name)}-ManagementGroups'
name: '${uniqueString(deployment().name)}-test-mmgcom'
params: {
// Required parameters
name: 'testMG'
name: '<<namePrefix>>mmgcom001'
// Non-required parameters
displayName: 'Test MG'
parentId: '<<managementGroupId>>'
parentId: '<parentId>'
}
}
```
Expand All @@ -166,14 +166,51 @@ module managementGroups './Microsoft.Management/managementGroups/deploy.bicep' =
"parameters": {
// Required parameters
"name": {
"value": "testMG"
"value": "<<namePrefix>>mmgcom001"
},
// Non-required parameters
"displayName": {
"value": "Test MG"
},
"parentId": {
"value": "<<managementGroupId>>"
"value": "<parentId>"
}
}
}
```

</details>
<p>

<h3>Example 2: Min</h3>

<details>

<summary>via Bicep module</summary>

```bicep
module managementGroups './Microsoft.Management/managementGroups/deploy.bicep' = {
name: '${uniqueString(deployment().name)}-test-mmgmin'
params: {
name: '<<namePrefix>>mmgmin001'
}
}
```

</details>
<p>

<details>

<summary>via JSON Parameter file</summary>

```json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<<namePrefix>>mmgmin001"
}
}
}
Expand Down