Azure / Azure/azure-cli

az resource update fails to add ip filter rules of an IotHub

Open
#31,631 3 comments 0 reactions 1 assignee Claimed by @zhoxing-ms View on GitHub
act-identity-squad ARM Auto-Assign Auto-Resolve Azure CLI Team customer-reported question
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

Hi I would like to add IP filter rules to IotHub, which has its `Public network access` configured to `All networks` using az cli.
See the image below.
![Image](https://github.com/user-attachments/assets/63c3b97c-35e0-48be-a86d-240378d617b8)

I need az cli command to change from `All networks` to `Selected IP ranges`

When I follow the [documentation](https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-ip-filtering#retrieve-and-update-ip-filters-using-azure-cli:~:text=To%20add%20a%20new%20IP%20filter%20for%20your%20IoT%20Hub%2C%20run) to add new IP filter, I always get an error message saying
```
(400059) Request body validation failed. If you contact a support representative please include this correlation identifier: 7c8311d2-683e-43d1-8de1-3e19c72251a5, timestamp: 2025-06-10 11:14:04Z, errorcode: IH400059
```

### Related command

az resource update -n $iotHubName -g $resourceGroup --resource-type Microsoft.Devices/IotHubs --add properties.networkRuleSets.ipRules "{\"action\":\"Allow\",\"filterName\":\"filterName\",\"ipMask\":\"10.39.6.128/25\"}"

### Errors

(400059) Request body validation failed. If you contact a support representative please include this correlation identifier: 7c8311d2-683e-43d1-8de1-3e19c72251a5, timestamp: 2025-06-10 11:14:04Z, errorcode: IH400059.
-43d1-8de1-3e19c72251a5, timestamp: 2025-06-10 11:14:04Z, errorcode: IH400059.
Code: 400059
Message: Request body validation failed. If you contact a support representative please include this correla-43d1-8de1-3e19c72251a5, timestamp: 2025-06-10 11:14:04Z, errorcode: IH400059.

### Issue script & Debug output

[debug log.txt](https://github.com/user-attachments/files/20676404/debug.log.txt)

### Expected behavior

I would expect the `az resource update` adds IP ranges to the Iot Hub network access

### Environment Summary

azure-cli 2.72.0 *

core 2.72.0 *
telemetry 1.1.0

Extensions:
azure-iot 0.26.0
gallery-service-artifact 1.0.0b1

Dependencies:
msal 1.32.3
azure-mgmt-resource 23.1.1

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\E1252566\.azure'
Extensions directory 'C:\Users\E1252566\.azure\cliextensions'

Python (Windows) 3.12.8 (tags/v3.12.8:2dc476b, Dec 3 2024, 19:30:04) [MSC v.1942 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

### Additional context

_No response_

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.