When I run this code to remediate azure storage I get the below error. I am new to azure policy and any help would be appreciated.
Original Link to the question and solution maybe the original person who submitted the answer could weigh in. Original Link
{
"properties": {
"displayName": "storage3",
"policyType": "Custom",
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Storage/storageAccounts"
},
{
"field": "Microsoft.Storage/storageAccounts/networkAcls.defaultAction",
"notEquals": "Deny"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Storage/storageAccounts",
"name": "[field('name')]",
"existenceCondition": {
"field": "Microsoft.Storage/storageAccounts/networkAcls.defaultAction",
"equals": "Deny"
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string"
},
"sku": {
"type": "string"
},
"location": {
"type": "string"
},
"kind": {
"type": "string"
}
},
"resources": [
{
"name": "[parameters('name')]",
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"location": "[parameters('location')]",
"properties": {
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [
{
"id": "",
"action": "Allow"
}
],
"ipRules": [],
"defaultAction": "Deny"
}
},
"dependsOn": [],
"sku": {
"name": "[parameters('sku')]"
},
"kind": "[parameters('kind')]"
}
]
},
"parameters": {
"name": {
"value": "[field('name')]"
},
"sku": {
"value": "[field('Microsoft.Storage/storageAccounts/sku.name')]"
},
"location": {
"value": "[field('location')]"
},
"kind": {
"value": "[field('kind')]"
}
}
}
}
}
}
}
}
}
ERROR
Deployment creation for policy definition '/subscriptions/xxxx-xxxx-xxxx-xxxx-xxxx/providers/Microsoft.Authorization/policyDefinitions/35df2d75-9090-45d4-8620-eca3e33bd5ac/' and assignment '/subscriptions/xxxx-xxxx-xxxx-xxxx-xxxx/providers/Microsoft.Authorization/policyAssignments/1ea05f4943d848dea7864f26/' was unsuccessful.
Details
Code InvalidTemplateDeployment
Message The template deployment 'PolicyDeployment_1961206787044174973' is not valid according to the validation procedure. The tracking id is '24b01fc6-b536-4422-b4bd-fdcc2fc14d87'. See inner errors for details.
Code PreflightValidationCheckFailed
Message Preflight validation failed. Please refer to the details for the specific errors.
Code InvalidValuesForRequestParameters
Message Values for request parameters are invalid: networkAcls.virtualNetworkRules[*].id. For more information, see - https://aka.ms/storagenetworkruleset
question from:
https://stackoverflow.com/questions/66067162/remediation-policy-for-network-restriction-of-azure-storage-account