You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Implementation/Policy/NewAzurePolicyAssignment.cs
The first command gets a resource group named ResourceGroup11 by using the Get-AzureRMResourceGroup cmdletand stores it in the $ResourceGroup variable.
63
-
The second command get the policy assignment named PolicyAssignment07 for the scope that the **ResourceId** property of $ResourceGroup identifies.
63
+
The second command gets the policy assignment named PolicyAssignment07 for the scope that the **ResourceId** property of $ResourceGroup identifies.
64
+
65
+
### Example 3: Get all policy assignments assigned to a management group
@@ -117,6 +118,17 @@ The first command gets a resource group named ResourceGroup11 by using the Get-A
117
118
The second command gets the built-in policy definition for allowed locations by using the Get-AzureRmPolicyDefinition cmdlet and stores it in the $Policy variable.
118
119
The final command assigns the policy in $Policy at the resource group identified by the **ResourceId** property of $ResourceGroup using the policy parameter file AllowedLocations.json from the local working directory.
119
120
121
+
### Example 4: Policy assignment with a managed identity
The first command gets a resource group named ResourceGroup11 by using the Get-AzureRMResourceGroup cmdlet and stores it in the $ResourceGroup variable.
129
+
The second command gets the policy definition named VirtualMachinePolicy by using the Get-AzureRmPolicyDefinition cmdlet and stores it in the $Policy variable.
130
+
The final command assigns the policy in $Policy to the resource gruop. A managed identity is automatically created and assigned to the policy assignment.
131
+
120
132
## PARAMETERS
121
133
122
134
### -ApiVersion
@@ -135,6 +147,21 @@ Accept pipeline input: False
135
147
Accept wildcard characters: False
136
148
```
137
149
150
+
### -AssignIdentity
151
+
Generate and assign an Azure Active Directory Identity for this policy assignment. The identity will be used when executing deployments for 'deployIfNotExists' policies.
This command creates a policy definition named LocationDefinition that contains the policy rule specified in C:\LocationPolicy.json. Example content for the LocationPolicy.json file is provided above.
63
+
64
+
### Example 2: Create a parameterized policy definition using inline parameters
This command creates a policy definition named LocationDefinition that contains the policy rule specified in C:\LocationPolicy.json. The parameter definition for the policy rule is provided inline.
51
82
52
-
### Example 2: Create a policy definition inline in a management group
83
+
### Example 3: Create a policy definition inline in a management group
This command creates a policy set definition named VMPolicyDefinition that contains the policy definitions specified in C:\VMPolicy.json.
67
+
This command creates a policy set definition named VMPolicyDefinition that contains the policy definitions specified in C:\VMPolicy.json. Example content of the VMPolicy.json is provided above.
68
+
69
+
### Example 2: Create a parameterized policy set definition
This command creates a parameterized policy set definition named VMPolicyDefinition that contains the policy definitions specified in C:\VMPolicy.json. Example content of the VMPolicy.json is provided above.
The first command gets the policy assignment named PolicyAssignment from the current subscription by using the Get-AzureRmPolicyAssignment cmdlet.
58
+
The command stores that object in the $PolicyAssignment variable.
59
+
The final command assigns a managed identity to the policy assignment.
60
+
51
61
## PARAMETERS
52
62
53
63
### -ApiVersion
@@ -66,6 +76,21 @@ Accept pipeline input: False
66
76
Accept wildcard characters: False
67
77
```
68
78
79
+
### -AssignIdentity
80
+
Generate and assign an Azure Active Directory Identity for this policy assignment. The identity will be used when executing deployments for 'deployIfNotExists' policies.
0 commit comments