Azure / Azure/azure-cli

az network application-gateway create - resets existing subnet and vnet address spaces

Open
#28,788 1 comment 0 reactions 1 assignee Claimed by @necusjz View on GitHub
act-quality-productivity-squad Auto-Assign Azure CLI Team Network potential-pruning question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

I've been having issues with the deployment of a new gateway on an existing Vnet and subnet. After several iterations trying to see what I could have misconfigured, I realized there is an ARM deployment that gets generated with the command, in which it looks like VNET and SUBNET information are overwritten by new address-prefixes for both the vnet and subnet.

To validate issues I tried out the CLI quickstart on this document: https://learn.microsoft.com/en-us/azure/application-gateway/quick-create-cli

1. This is how my subnets look like when going through Quickstart, before running the app gateway `create` command.

![image](https://github.com/Azure/azure-cli/assets/838216/91ddad2b-17df-4a05-ac56-6652c0a5cbe3)

2. Then I execute the app gateway `create` command, notice how my subnets have been reset: one is deleted and the address space for the vnet and subnet have been reset to something totally different.

![image](https://github.com/Azure/azure-cli/assets/838216/814c2f25-f339-41fd-9fe0-6d2da139783e)

### Related command

```
az network application-gateway create \
--name myAppGateway \
--location eastus \
--resource-group $RESOURCE_GROUP \
--capacity 2 \
--sku Standard_v2 \
--public-ip-address myAGPublicIPAddress \
--vnet-name myVNet \
--subnet myAGSubnet \
--servers "www.uri2.com" "uri2" \
--priority 100
```

### Errors

In this case there is no error generated but the command has deleted by subnet called `myBackendSubnet` which is a problem to deploy in any real environment.
Additionally the Public IP used had a DNS label set, and this has now been reset (removed the DNS label).

### Issue script & Debug output

To repro the same behavior, follow the Quickstart and wonder if you can reproduce the vnet and subnets reset and deletion.
For repro of the Public IP DNS reset, change that command to something like (note the `--dns-name`):
`az network public-ip create --resource-group $RESOURCE_GROUP --name myAGPublicIPAddress --allocation-method Static --sku Standard --dns-name MYCUSTOMLABEL`

### Expected behavior

When passing in a subnet Resource ID, or an existing vnet and subnet name, this command should deploy the app gateway in the chosen subnet but not delete any other subnets, or reset the address space for those.

### Environment Summary

azure-cli 2.59.0

core 2.59.0
telemetry 1.1.0

Extensions:
azure-iot 0.23.1
azure-iot-ops 0.4.0b3
connectedk8s 1.6.7
k8s-extension 1.6.1

Dependencies:
msal 1.27.0
azure-mgmt-resource 23.1.0b2

Python location '/opt/az/bin/python3'
Extensions directory '/home/[...]/.azure/cliextensions'

Python (Linux) 3.11.8 (main, Mar 27 2024, 04:03:26) [GCC 9.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

### Additional context

I also did test with my own VNET and SUBNETs, including the NSG to allow GatewayManager on ports `65200-65535` set correctly upfront and it still deletes and recreates the address space and subnet.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.