Azure / Azure/PSRule.Rules.Azure
[BUG] Export-AzPolicyAssignmentRuleData unable to export Azure policy as PSRule (The function "field" was not found) [Custom policy: Prevent cross subscription Private Link]
- Dominant language
- PowerShell
- Stars
- 447
- Forks
- 109
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 23
Description
### Existing rule
_No response_
### Description of the issue
Unable to export policy assignment data to PSRule.
```json
{
"Name": "00000000-0000-0000-0000-000000000000",
"ResourceId": "/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/00000000-0000-0000-0000-000000000000",
"ResourceName": "00000000-0000-0000-0000-000000000000",
"ResourceType": "Microsoft.Authorization/policyDefinitions",
"SubscriptionId": null,
"Properties": {
"Description": "This policy prevents private link between subscriptions.",
"DisplayName": "Prevent cross subscription Private Link",
"Metadata": {
"version": "0.0.2",
"category": "Network",
"status": "Active",
"Control": "ABC1, ABC2, ABC3, ABC4, ABC5",
"purpose": "This policy prevents private link between subscriptions.",
"tags": [
{
"managedpolicy": "true"
}
],
"createdBy": "00000000-0000-0000-0000-000000000000",
"createdOn": "2023-06-14T14:18:35.23436Z",
"updatedBy": null,
"updatedOn": null
},
"Mode": "All",
"Parameters": {
"effect": {
"type": "String",
"metadata": {
"description": "The effect of the policy",
"displayName": "Effect"
},
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"defaultValue": "Deny"
}
},
"PolicyRule": {
"if": {
"allOf": [
{
"equals": "Microsoft.Network/privateEndpoints",
"field": "type"
},
{
"anyOf": [
{
"allOf": [
{
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*].privateLinkServiceId",
"notContains": "[concat('/subscriptions/',split(field('id'),'/')[2])]"
},
{
"greater": 0,
"value": "[length(field('Microsoft.Network/privateEndpoints/privateLinkServiceConnections'))]"
}
]
},
{
"allOf": [
{
"field": "Microsoft.Network/privateEndpoints/manualPrivateLinkServiceConnections[*].privateLinkServiceId",
"notContains": "[concat('/subscriptions/',split(field('id'),'/')[2])]"
},
{
"greater": 0,
"value": "[length(field('Microsoft.Network/privateEndpoints/manualPrivateLinkServiceConnections'))]"
}
]
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"PolicyType": 1
},
"PolicyDefinitionId": "/providers/Microsoft.Management/managementGroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/00000000-0000-0000-0000-000000000000"
}
```
### Error messages
An error occurred evaluating expression '[concat('/subscriptions/',split(field('id'),'/')[2])]' line 55. The function "field" was not found.
### Reproduction
Exporting policy assignment data
### Version of PSRule
2.9.0
### Version of PSRule for Azure
1.33.2
### Additional context
This bug is related to #1323
Contributor guide
Assessment
This issue has not been assessed yet.