3
3
4
4
using System ;
5
5
using System . Collections . Generic ;
6
- using System . Management . Automation . Language ;
7
6
using Newtonsoft . Json . Linq ;
8
7
9
8
namespace PSRule . Rules . Azure . Data . Template ;
@@ -58,6 +57,7 @@ internal sealed class RuleDataExportVisitor : TemplateVisitor
58
57
private const string TYPE_KEYVAULT = "Microsoft.KeyVault/vaults" ;
59
58
private const string TYPE_STORAGE_OBJECTREPLICATIONPOLICIES = "Microsoft.Storage/storageAccounts/objectReplicationPolicies" ;
60
59
private const string TYPE_AUTHORIZATION_ROLE_ASSIGNMENTS = "Microsoft.Authorization/roleAssignments" ;
60
+ private const string TYPE_MANAGEMENT_GROUPS = "Microsoft.Management/managementGroups" ;
61
61
62
62
private static readonly JsonMergeSettings _MergeSettings = new ( )
63
63
{
@@ -138,6 +138,7 @@ private static void ProjectRuntimeProperties(TemplateContext context, IResourceV
138
138
ProjectStorageObjectReplicationPolicies ( context , resource ) ||
139
139
ProjectKeyVault ( context , resource ) ||
140
140
ProjectRoleAssignments ( context , resource ) ||
141
+ ProjectManagementGroup ( context , resource ) ||
141
142
ProjectResource ( context , resource ) ;
142
143
}
143
144
@@ -157,6 +158,22 @@ private static bool ProjectResource(TemplateContext context, IResourceValue reso
157
158
return true ;
158
159
}
159
160
161
+ private static bool ProjectManagementGroup ( TemplateContext context , IResourceValue resource )
162
+ {
163
+ if ( ! resource . IsType ( TYPE_MANAGEMENT_GROUPS ) )
164
+ return false ;
165
+
166
+ resource . Value . UseProperty ( PROPERTY_PROPERTIES , out JObject properties ) ;
167
+
168
+ // Add properties.tenantId
169
+ if ( ! properties . ContainsKeyInsensitive ( PROPERTY_TENANT_ID ) )
170
+ {
171
+ properties [ PROPERTY_TENANT_ID ] = context . Tenant . TenantId ;
172
+ }
173
+
174
+ return true ;
175
+ }
176
+
160
177
private static bool ProjectRoleAssignments ( TemplateContext context , IResourceValue resource )
161
178
{
162
179
if ( ! resource . IsType ( TYPE_AUTHORIZATION_ROLE_ASSIGNMENTS ) )
0 commit comments