Skip to content

Commit 924eb68

Browse files
azure-pipelines[bot]azure-powershell-botLei jin
authored
Migrate Resources from generation to main (#26129)
* Move Resources to main * Add change log --------- Co-authored-by: azure-powershell-bot <[email protected]> Co-authored-by: Lei jin <[email protected]>
1 parent 1552e99 commit 924eb68

File tree

307 files changed

+13555
-9377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+13555
-9377
lines changed

src/Resources/Authorization.Autorest/Az.Authorization.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
GUID = '75928d90-d5c7-49aa-b368-3856a02003be'
2+
GUID = '87ef2602-2a5d-4f33-8ec1-e58f24d6d474'
33
RootModule = './Az.Authorization.psm1'
44
ModuleVersion = '0.1.0'
55
CompatiblePSEditions = 'Core', 'Desktop'

src/Resources/Authorization.Autorest/help/Az.Authorization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Module Name: Az.Authorization
3-
Module Guid: 75928d90-d5c7-49aa-b368-3856a02003be
3+
Module Guid: 87ef2602-2a5d-4f33-8ec1-e58f24d6d474
44
Download Help Link: https://learn.microsoft.com/powershell/module/az.authorization
55
Help Version: 1.0.0.0
66
Locale: en-US

src/Resources/Policy.Autorest/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,12 +282,10 @@ directive:
282282
- DisplayName
283283

284284
# Hide parameters that aren't supported.
285-
# For some reason these can't be hidden by hiding them in
286-
# the custom folder so we have to do it here.
287285
- where:
288286
verb: New|Update
289287
subject: PolicyAssignment|PolicyExemption
290-
parameter-name: PolicyDefinitionId|ResourceSelector|Override
288+
parameter-name: PolicyDefinitionId
291289
hide: true
292290
- where:
293291
verb: New

src/Resources/Policy.Autorest/custom/New-AzPolicyAssignment.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ param(
153153
# To construct, see NOTES section for NONCOMPLIANCEMESSAGE properties and create a hash table.
154154
${NonComplianceMessage},
155155

156+
[Parameter()]
157+
[AllowEmptyCollection()]
158+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
159+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IOverride[]]
160+
# The policy property value override.
161+
${Override},
162+
163+
[Parameter()]
164+
[AllowEmptyCollection()]
165+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
166+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelector[]]
167+
# The resource selector list to filter policies by resource properties.
168+
${ResourceSelector},
169+
156170
[Parameter()]
157171
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
158172
[System.Management.Automation.SwitchParameter]

src/Resources/Policy.Autorest/custom/New-AzPolicyExemption.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ param(
105105
# Metadata is an open ended object and is typically a collection of key value pairs.
106106
${Metadata},
107107

108+
[Parameter()]
109+
[AllowEmptyCollection()]
110+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
111+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelector[]]
112+
# The resource selector list to filter policies by resource properties.
113+
${ResourceSelector},
114+
108115
[Parameter()]
109116
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
110117
[System.Management.Automation.SwitchParameter]

src/Resources/Policy.Autorest/custom/Update-AzPolicyAssignment.ps1

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,20 @@ param(
160160
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IPolicyAssignment]
161161
${InputObject},
162162

163+
[Parameter()]
164+
[AllowEmptyCollection()]
165+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
166+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IOverride[]]
167+
# The policy property value override.
168+
${Override},
169+
170+
[Parameter()]
171+
[AllowEmptyCollection()]
172+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
173+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelector[]]
174+
# The resource selector list to filter policies by resource properties.
175+
${ResourceSelector},
176+
163177
[Parameter()]
164178
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
165179
[System.Management.Automation.SwitchParameter]
@@ -279,7 +293,7 @@ process {
279293
if ($InputObject) {
280294
foreach ($parameterName in $InputObject.Keys) {
281295
$value = $InputObject.($parameterName)
282-
if ($value -or ($value -is [array])) {
296+
if ($value -or ($value -is [array]) -or ($value -is [switch])) {
283297
$calledParameters.($parameterName) = $value
284298
}
285299
}
@@ -288,7 +302,7 @@ process {
288302
# skip $null and empty values to avoid validation failures on pipeline input
289303
foreach ($parameterName in $PSBoundParameters.Keys) {
290304
$value = $PSBoundParameters.($parameterName)
291-
if ($value -or ($value -is [array])) {
305+
if ($value -or ($value -is [array]) -or ($value -is [switch])) {
292306
$calledParameters.($parameterName) = $value
293307
}
294308
}

src/Resources/Policy.Autorest/custom/Update-AzPolicyDefinition.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ process {
220220
if ($InputObject) {
221221
foreach ($parameterName in $InputObject.Keys) {
222222
$value = $InputObject.($parameterName)
223-
if ($value -or ($value -is [array])) {
223+
if ($value -or ($value -is [array]) -or ($value -is [switch])) {
224224
$calledParameters.($parameterName) = $value
225225
}
226226
}
@@ -229,7 +229,7 @@ process {
229229
# skip $null and empty values to avoid validation failures on pipeline input
230230
foreach ($parameterName in $PSBoundParameters.Keys) {
231231
$value = $PSBoundParameters.($parameterName)
232-
if ($value -or ($value -is [array])) {
232+
if ($value -or ($value -is [array]) -or ($value -is [switch])) {
233233
$calledParameters.($parameterName) = $value
234234
}
235235
}

src/Resources/Policy.Autorest/custom/Update-AzPolicyExemption.ps1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ param(
109109
${InputObject},
110110

111111
[Parameter()]
112-
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
113-
[System.Management.Automation.SwitchParameter]
114-
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
115-
${BackwardCompatible} = $false,
112+
[AllowEmptyCollection()]
113+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Category('Body')]
114+
[Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IResourceSelector[]]
115+
# The resource selector list to filter policies by resource properties.
116+
${ResourceSelector},
116117

117118
[Parameter()]
118119
[ValidateSet('Default', 'DoNotValidate')]
@@ -122,6 +123,12 @@ param(
122123
# The option whether validate the exemption is at or under the assignment scope.
123124
${AssignmentScopeValidation},
124125

126+
[Parameter()]
127+
[Obsolete('This parameter is a temporary bridge to new types and formats and will be removed in a future release.')]
128+
[System.Management.Automation.SwitchParameter]
129+
# Causes cmdlet to return artifacts using legacy format placing policy-specific properties in a property bag object.
130+
${BackwardCompatible} = $false,
131+
125132
[Parameter()]
126133
[Alias('AzureRMContext', 'AzureCredential')]
127134
[ValidateNotNull()]
@@ -221,7 +228,7 @@ process {
221228
if ($InputObject) {
222229
foreach ($parameterName in $InputObject.Keys) {
223230
$value = $InputObject.($parameterName)
224-
if ($value -or ($value -is [array])) {
231+
if ($value -or ($value -is [array]) -or ($value -is [switch])) {
225232
$calledParameters.($parameterName) = $value
226233
}
227234
}
@@ -230,7 +237,7 @@ process {
230237
# skip $null and empty values to avoid validation failures on pipeline input
231238
foreach ($parameterName in $PSBoundParameters.Keys) {
232239
$value = $PSBoundParameters.($parameterName)
233-
if ($value -or ($value -is [array])) {
240+
if ($value -or ($value -is [array]) -or ($value -is [switch])) {
234241
$calledParameters.($parameterName) = $value
235242
}
236243
}

src/Resources/Policy.Autorest/custom/Update-AzPolicySetDefinition.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ process {
221221
if ($InputObject) {
222222
foreach ($parameterName in $InputObject.Keys) {
223223
$value = $InputObject.($parameterName)
224-
if ($value -or ($value -is [array])) {
224+
if ($value -or ($value -is [array]) -or ($value -is [switch])) {
225225
$calledParameters.($parameterName) = $value
226226
}
227227
}
@@ -230,7 +230,7 @@ process {
230230
# skip $null and empty values to avoid validation failures on pipeline input
231231
foreach ($parameterName in $PSBoundParameters.Keys) {
232232
$value = $PSBoundParameters.($parameterName)
233-
if ($value -or ($value -is [array])) {
233+
if ($value -or ($value -is [array]) -or ($value -is [switch])) {
234234
$calledParameters.($parameterName) = $value
235235
}
236236
}

src/Resources/Policy.Autorest/examples/New-AzPolicyAssignment.md

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,25 @@ The final command assigns the policy in $Policy at the level of a resource group
3939
The **ResourceId** property of $ResourceGroup identifies the resource group.
4040

4141
### Example 4: Policy assignment at resource group level with policy parameter file
42-
Create a file called _AllowedLocations.json_ in the local working directory with the following content.
43-
4442
```powershell
45-
{
43+
'{
4644
"listOfAllowedLocations": {
4745
"value": [
4846
"westus",
4947
"westeurope",
5048
"japanwest"
5149
]
5250
}
53-
}
51+
}' > .\AllowedLocations.json
5452
5553
$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
5654
$Policy = Get-AzPolicyDefinition -BuiltIn | Where-Object {$_.DisplayName -eq 'Allowed locations'}
5755
New-AzPolicyAssignment -Name 'RestrictLocationPolicyAssignment' -PolicyDefinition $Policy -Scope $ResourceGroup.ResourceId -PolicyParameter .\AllowedLocations.json
5856
```
5957

60-
The first command gets a resource group named ResourceGroup11 by using the Get-AzResourceGroup cmdlet and stores it in the $ResourceGroup variable.
61-
The second command gets the built-in policy definition for allowed locations by using the Get-AzPolicyDefinition cmdlet and stores it in the $Policy variable.
58+
The first command creates a parameter file called _AllowedLocations.json_ in the local working directory.
59+
The second command gets a resource group named ResourceGroup11 by using the Get-AzResourceGroup cmdlet and stores it in the $ResourceGroup variable.
60+
The third command gets the built-in policy definition for allowed locations by using the Get-AzPolicyDefinition cmdlet and stores it in the $Policy variable.
6261
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.
6362

6463
### Example 5: Policy assignment with a system assigned managed identity
@@ -108,7 +107,31 @@ The first command gets the policy set definition named VirtualMachinePolicySet b
108107
The second command creates an array of non-compliance messages. One general purpose message for the entire assignment and one message specific to a SKU restriction policy within the assigned policy set definition.
109108
The final command assigns the policy set definition in $PolicySet to the subscription with two non-compliance messages that will be shown if a resource is denied by policy.
110109

111-
### Example 9: [Backcompat] Policy assignment at resource group level with policy parameter object
110+
### Example 9: Policy assignment with resource selector
111+
```powershell
112+
$Policy = Get-AzPolicyDefinition -Name 'VirtualMachinePolicy'
113+
$ResourceSelector = @{Name = "MyLocationSelector"; Selector = @(@{Kind = "resourceLocation"; In = @("eastus", "eastus2")})}
114+
New-AzPolicyAssignment -Name 'VirtualMachinePolicyAssignment' -PolicyDefinition $Policy -ResourceSelector $ResourceSelector
115+
```
116+
117+
The first command gets the policy definition named VirtualMachinePolicy by using the Get-AzPolicyDefinition cmdlet and stores it in the $Policy variable.
118+
The second command creates a resource selector object that will be used to specify the assignment should only apply to resources located in East US or East US 2 and stores it in the $ResourceSelector variable.
119+
The final command assigns the policy definition in $Policy to the subscription with the resource selector specified by $ResourceSelector.
120+
121+
### Example 10: Policy assignment with override
122+
```powershell
123+
$Policy = Get-AzPolicyDefinition -Name 'VirtualMachinePolicy'
124+
$Selector = @{Kind = "resourceLocation"; In = @("eastus", "eastus2")}
125+
$Override = @(@{Kind = "policyEffect"; Value = 'Disabled'; Selector = @($Selector)})
126+
New-AzPolicyAssignment -Name 'VirtualMachinePolicyAssignment' -PolicyDefinition $Policy -Override $Override
127+
```
128+
129+
The first command gets the policy definition named VirtualMachinePolicy by using the Get-AzPolicyDefinition cmdlet and stores it in the $Policy variable.
130+
The second command creates a location selector specifying East US or East US 2 locations and stores it in the $Selector variable.
131+
The third command creates an override object that will be used to specify that the assigned definition should have a Disabled effect in the locations identified by the $Selector object and stores it in the $Override variable.
132+
The final command assigns the policy definition in $Policy to the subscription with the override specified by $Override.
133+
134+
### Example 11: [Backcompat] Policy assignment at resource group level with policy parameter object
112135
```powershell
113136
$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
114137
$Policy = Get-AzPolicyDefinition -BuiltIn | Where-Object {$_.Properties.DisplayName -eq 'Allowed locations'}
@@ -126,25 +149,24 @@ The commands store that object in the $AllowedLocations variable.
126149
The final command assigns the policy in $Policy at the level of a resource group using the policy parameter object in $AllowedLocations.
127150
The **ResourceId** property of $ResourceGroup identifies the resource group.
128151

129-
### Example 10: [Backcompat] Policy assignment at resource group level with policy parameter file
130-
Create a file called _AllowedLocations.json_ in the local working directory with the following content.
131-
152+
### Example 12: [Backcompat] Policy assignment at resource group level with policy parameter file
132153
```powershell
133-
{
154+
'{
134155
"listOfAllowedLocations": {
135156
"value": [
136157
"westus",
137158
"westeurope",
138159
"japanwest"
139160
]
140161
}
141-
}
162+
}' > .\AllowedLocations.json
142163
143164
$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup11'
144165
$Policy = Get-AzPolicyDefinition -BuiltIn | Where-Object {$_.Properties.DisplayName -eq 'Allowed locations'}
145166
New-AzPolicyAssignment -Name 'RestrictLocationPolicyAssignment' -PolicyDefinition $Policy -Scope $ResourceGroup.ResourceId -PolicyParameter .\AllowedLocations.json
146167
```
147168

148-
The first command gets a resource group named ResourceGroup11 by using the Get-AzResourceGroup cmdlet and stores it in the $ResourceGroup variable.
149-
The second command gets the built-in policy definition for allowed locations by using the Get-AzPolicyDefinition cmdlet and stores it in the $Policy variable.
169+
The first command creates a parameter file called _AllowedLocations.json_ in the local working directory.
170+
The second command gets a resource group named ResourceGroup11 by using the Get-AzResourceGroup cmdlet and stores it in the $ResourceGroup variable.
171+
The third command gets the built-in policy definition for allowed locations by using the Get-AzPolicyDefinition cmdlet and stores it in the $Policy variable.
150172
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.

0 commit comments

Comments
 (0)