"Alias request: "Microsoft.Network/virtualNetworks/resourceGroups"
Scenario
What are you trying to achieve using Azure Policy?
Allow VNET creation only from particular resource group
Example policy definition
Please include a sample policy definition that shows how you would like to use this new alias. { "mode": "All", "policyRule": { "if": { "allOf": [ { "field": "type", "equals": "Microsoft.Network/virtualNetworks" }, { "field": "Microsoft.Network/virtualNetworks/resourceGroups", "notcontains": "[concat('resourceGroups/',parameters('resourceGroupName'))]" } ] }, "then": { "effect": "deny" } }, "parameters": { "resourceGroupName": { "type": "String", "metadata": { "displayName": "Resource Group Name", "description": null, "strongType": "ExistingResourceGroups" } } } }
@jayaakshayan
There is a policy function that will return the resource group. Below is the section of your policy definition that I would recommend replacing with the example below that uses the "resourcegroup().name) function:
Instead of this:
"field": "Microsoft.Network/virtualNetworks/resourceGroups",
"notcontains": "[concat('resourceGroups/',parameters('resourceGroupName'))]"
Try this:
"value": "[resourceGroup().name]",
"notEquals": "[parameters('resourceGroupName')]"
Here are some links on the documentation regarding this. Do a search for "resourcegroup" on these pages and you can see more examples: https://docs.microsoft.com/en-us/azure/governance/policy/concepts/definition-structure#policy-function-example
https://docs.microsoft.com/en-us/azure/governance/policy/concepts/definition-structure#value-examples
The full set of aliases for Microsoft.Network/virtualNetworks has been published. That does not include an alias for ResourceGroups which isn't a payload field that can have policies applied. The suggestion above by @mylameaccount is a good approach for that scenario.
Thanks Lame & Mentat, I have used the same approach and achieved what i required.
"value": "[resourceGroup().name]",
"notEquals": "[parameters('resourceGroupName')]"