Hello.
I'm facing the same issue. I just created a virtual machine, witch created the nsg. I wanted to add a rule but got the same error on the azure portal and also CLI.
Tried to clear the browser data also (cookies, local storage).
Here is what I can see about the request when I add --debug flag to the cli command:
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/*******/resourceGroups/*******/providers/Microsoft.Network/networkSecurityGroups/*******/securityRules/r1?api-version=2022-01-01'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'Content-Length': '240'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': '********'
cli.azure.cli.core.sdk.policies: 'CommandName': 'network nsg rule create'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '--resource-group --nsg-name --name --priority --direction --access --protocol --source-address-prefixes --source-port-ranges --destination-address-prefixes --destination-port-ranges --debug'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.76.0 (MSI) azsdk-python-core/1.35.0 Python/3.12.10 (Windows-11-10.0.26100-SP0)'
cli.azure.cli.core.sdk.policies: 'Authorization': '*****'
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"name": "r1", "properties": {"access": "Allow", "destinationAddressPrefix": "*", "destinationPortRange": "6333", "direction": "Inbound", "priority": 300, "protocol": "Tcp", "sourceAddressPrefix": "***.***.***.***", "sourcePortRange": "*"}}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions/*******/resourceGroups/********/providers/Microsoft.Network/networkSecurityGroups/********/securityRules/r1?api-version=2022-01-01 HTTP/1.1" 400 346
cli.azure.cli.core.sdk.policies: Response status: 400
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Content-Length': '346'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'text/html; charset=us-ascii'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'x-ms-operation-identifier': 'tenantId=********,objectId=********/northeurope/********'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-writes': '199'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-global-writes': '2999'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '********'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '********'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'NORTHEUROPE:*******'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: ******** Ref B: ******* Ref C: 2025-08-28T19:10:51Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Thu, 28 Aug 2025 19:10:50 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Bad Request - Request Too Long</h2>
<hr><p>HTTP Error 400. The size of the request headers is too long.</p>
</BODY></HTML>