204051 - Failed to Create an NSG Rule
Uploading...Agent error code #204051 indicates that az network nsg rule create failed. This is the operation that grants a user access.
Common causes include:
Steps to Resolve
Confirm the Service Principal Can Write
Read access is not enough. The agent has to create and delete rules.
Microsoft.Network/networkSecurityGroups/securityRules/write
Scope it to the NSG or its resource group
Check the Rule Count
Azure limits the number of rules per NSG.
kk- prefix, so stale entries are easy to spot
Remove stale rules or request a quota increase
Look for a Lock or Policy
Reproduce the Call by Hand
sudo -u knocknoc az network nsg rule create \
--resource-group <resource-group> --nsg-name <nsg-name> \
--name kk-test --priority 900 --access Allow --protocol Tcp \
--destination-port-ranges <port> --source-address-prefixes 192.0.2.1/32
Remember to delete the test rule afterwards.