Update programmatically (using Azure REST API or .NET SDK) IP address ranges of an Azure Cosmos DB Firewall

Milen Denev 91 Reputation points
2021-11-05T17:13:52.6+00:00

I am trying to find how to update the IP address ranges using the Azure REST API (or .NET SDK). The documentation seems to do not have any information.
I tried different requests here https://management.azure.com//subscriptions/{subscriptionId}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/firewall without success.
Something similar for Azure SQL REST API: https://learn.microsoft.com/en-us/rest/api/sql/2021-02-01-preview/firewall-rules/create-or-update

Azure Firewall
Azure Firewall
An Azure network security service that is used to protect Azure Virtual Network resources.
564 questions
Azure Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,131 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,438 questions
0 comments No comments
{count} votes

Accepted answer
  1. Saurabh Sharma 23,671 Reputation points Microsoft Employee
    2021-11-05T21:42:56.65+00:00

    Hi @Milen Denev ,

    Thanks for using Microsoft Q&A !!
    You can use Update Rest API to update IP Address ranges.
    You need to pass only properties you want to update as part of this API request body while calling the API.
    Your API Request URL will look like below -
    PATCH https://management.azure.com/subscriptions/{Subscription Id}/resourceGroups/{Resource Group}/providers/Microsoft.DocumentDB/databaseAccounts/{Account Name}?api-version=2021-04-15

    API request body will be like below:

    {  
          "location": "westus",  
           "properties": {  
           "databaseAccountOfferType": "Standard",  
           "ipRules": [  
          {  
            "ipAddressOrRange": "23.43.230.120"  
          },  
          {  
            "ipAddressOrRange": "110.12.240.0/12"  
          }  
        ]  
         }  
    }  
    

    Result:
    146900-image.png

    Please let me know if you have any questions.

    Thanks
    Saurabh

    ----------

    Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.


0 additional answers

Sort by: Most helpful