Skip to content

Commit 459d0f5

Browse files
committed
Rollback Az.Resources Azure#2970
1 parent 6a2e367 commit 459d0f5

File tree

5 files changed

+57
-26
lines changed

5 files changed

+57
-26
lines changed

docs/CHANGELOG-v1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ See [upgrade notes][1] for helpful information when upgrading from previous vers
3333
- Cosmos DB:
3434
- Verify that Cosmos DB accounts have continuous backup configured by @BenjaminEngeset.
3535
[#2954](https://github.com/Azure/PSRule.Rules.Azure/issues/2954)
36+
- Bug fixes:
37+
- Rollback Az.Resources to v6.16.2.
38+
[#2970](https://github.com/Azure/PSRule.Rules.Azure/issues/2970)
3639

3740
## v1.38.0-B0068 (pre-release)
3841

docs/concepts/policy-as-rules.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,40 @@ Key points:
5252
- This command has no required parameters, and by default will export all assignments from you current Azure subscription.
5353
You can change the current Azure subscription by using `Set-AzContext`.
5454

55+
!!! Bug
56+
Currently a known incompatibility exists with 7.x of `Az.Resources` which introduced a breaking change.
57+
Please use `Az.Resources` >= v6.7.0 and < v7.0.0.
58+
For more information see [Issues with Az.Resources](../troubleshooting.md#issues-with-azresources)
59+
60+
For example:
61+
62+
```powershell title="PowerShell"
63+
# Install and import required modules.
64+
Install-Module Az.Resources -RequiredVersion '6.16.2' -Force -Scope CurrentUser
65+
Import-Module Az.Resources -RequiredVersion '6.16.2'
66+
Import-Module PSRule.Rules.Azure
67+
68+
# Connect to Azure
69+
Connect-AzAccount
70+
Set-AzContext -Subscription '<subscriptionId>'
71+
72+
# Export assignments
73+
Export-AzPolicyAssignmentData
74+
```
75+
5576
### Convert assignments to rules
5677

5778
Run `Export-AzPolicyAssignmentRuleData` to convert assignments to rules.
5879
To run this command an `-AssignmentFile` parameter with the path to the assignment JSON file generated in the previous step.
5980

6081
After the command completes a new file `*.Rule.jsonc` should be generated containing generated rules.
6182

83+
For example:
84+
85+
```powershell title="PowerShell"
86+
Export-AzPolicyAssignmentRuleData -AssignmentFile '.\<subscriptionId>.assignment.json'
87+
```
88+
6289
## Customizing the generated rules
6390

6491
PSRule for Azure allows you to:

docs/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ PowerShell modules:
158158
In most cases these modules will be pre-installed on the CI worker.
159159
For private CI workers, consider pre-installing these modules in a previous step.
160160
161-
[3]: troubleshooting.md#an-earlier-version-of-azaccounts-is-imported
161+
[3]: troubleshooting.md#issues-with-azresources
162162
163163
### Installing PowerShell
164164

docs/troubleshooting.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -169,50 +169,51 @@ This doesn't affect the workings of the parameter file or deployment.
169169
The reason for the warning is that the `metadata` property has not been added to the parameter file JSON schema.
170170
However, the top level `metadata` property is ignored by Azure Resource Manager when deploying a template.
171171

172-
## A warning is reported for Az.Resources
172+
## Issues with Az.Resources
173173

174-
When running PSRule or importing `PSRule.Rules.Azure` on the command-line you see a message similar to the following:
174+
The PowerShell module `Az.Resources` and `Az.Accounts` is currently used when exporting data from Azure.
175+
These modules are use when:
176+
177+
- Exporting resources for in-flight analysis.
178+
- Exporting policy assignments for policy as rules.
179+
180+
These modules are not required if you only want to execute rules.
181+
182+
### Suppression of Az.Resources warning
183+
184+
If you only intend to execute rules you can suppress the following warning message.
175185

176186
!!! Message
177187

178188
To use PSRule for Azure export cmdlets please install Az.Resources.
179189

180-
This warning flags that when running `Export-*` cmdlets for PSRule for Azure, the `Az.Resources` module is required.
181-
If you intend to call these cmdlets, first install the `Az.Resources` module.
182-
Otherwise this warning message can be ignored.
183-
190+
This message can be ignored if you are not exporting data from Azure.
184191
To suppress the warning configure the `PSRULE_AZURE_RESOURCE_MODULE_NOWARN` environment variable to `true`.
185192
For more details see [Configuring exports](setup/configuring-exports.md#psrule_azure_resource_module_nowarn).
186193

187-
## An earlier version of Az.Accounts is imported
194+
### Installing Az.Resources
195+
196+
If you plan on exporting data from Azure, you must install the `Az.Resources` module.
188197

189-
When running PSRule for Azure in Azure DevOps within the `AzurePowerShell@5` task,
190-
you may see the following error.
198+
Some versions of `Az.Resources` are known to be incompatible with PSRule for Azure.
199+
As a result, we recommend installing and importing v6.16.2 to address these issues.
200+
A known incompatibility currently exists with v7.1.0 ([#2970](https://github.com/Azure/PSRule.Rules.Azure/issues/2970)).
201+
By default, PowerShell will attempt to install or use a newer version already installed which may return an error.
191202

192203
!!! Message
193204

194-
This module requires Az.Accounts version 2.8.0. An earlier version of
195-
Az.Accounts is imported in the current PowerShell session. Please open a new
196-
session before importing this module. This error could indicate that multiple
197-
incompatible versions of the Azure PowerShell cmdlets are installed on your
198-
system. Please see https://aka.ms/azps-version-error for troubleshooting
199-
information.
205+
ExpandPolicyAssignment: The property 'Properties' cannot be found on this object. Verify that the property exists.
200206

201-
This error is raised by a chained dependency failure importing a newer version of `Az.Accounts`.
202-
To avoid this issue attempt to install the exact versions of `Az.Resources`.
203-
In the `AzurePowerShell@5` task before installing PSRule.
207+
To install a specific version use:
204208

205209
```powershell title="PowerShell"
206-
Install-Module Az.Resources -RequiredVersion '7.1.0' -Force -Scope CurrentUser
210+
Install-Module Az.Resources -RequiredVersion '6.16.2' -Force -Scope CurrentUser
207211
```
208212

209-
From PSRule for Azure v1.16.0, `Az.Accounts` and `Az.Resources` are no longer installed as dependencies.
210-
When using export commands from PSRule, you may need to install these modules.
211-
212-
To install these modules, use the following PowerShell command:
213+
To import a specific version prior to using PSRule:
213214

214215
```powershell title="PowerShell"
215-
Install-Module Az.Resources -Force -Scope CurrentUser
216+
Import-Module Az.Resources -RequiredVersion '6.16.2'
216217
```
217218

218219
## Could not load file or assembly YamlDotNet

modules.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"devDependencies": {
88
"Az.Resources": {
9-
"version": "7.1.0"
9+
"version": "6.16.2"
1010
},
1111
"Pester": {
1212
"version": "5.6.0"

0 commit comments

Comments
 (0)