Triage and Remediation
Remediation
Using Console
Using Console
To remediate the misconfiguration “Restrict Default Network Access for Azure Cosmos DB Accounts” in Azure using the Azure console, follow these steps:
- Log in to the Azure portal (https://portal.azure.com/).
- Navigate to the Azure Cosmos DB account for which you want to restrict network access.
- Click on the “Firewalls and virtual networks” tab.
- Under the “Firewall” section, select “Enabled”.
- Under the “Virtual networks” section, select the virtual network that you want to allow access to.
- Under the “Subnets” section, select the subnet that you want to allow access to.
- Click on “Save” to apply the changes.
Using CLI
Using CLI
To remediate the misconfiguration “Restrict Default Network Access for Azure Cosmos DB Accounts” in Azure using Azure CLI, follow the below steps:Note: Replace the placeholders
- Open the Azure CLI on your local machine or use the Azure Cloud Shell.
- Login to your Azure account using the command
az login
. - Once logged in, select the subscription you want to work with using the command
az account set --subscription <subscription_id>
. - Get the list of Cosmos DB accounts in the selected subscription using the command
az cosmosdb list
. - Choose the Cosmos DB account for which you want to restrict default network access.
- Run the following command to update the Cosmos DB account settings to restrict default network access:
<cosmos_db_account_name>
, <resource_group_name>
, <consistency_level>
, <region_name>
, and <subscription_id>
with the actual values.- Once the command is executed successfully, the default network access for the Cosmos DB account will be restricted.
Using Python
Using Python
To restrict default network access for Azure Cosmos DB Accounts using Python, you can follow these steps:The complete code will look like this:Note: Replace “your_cosmos_db_account_endpoint” and “your_cosmos_db_account_key” with the actual values of your Cosmos DB account.
- Import the necessary modules:
- Create a Cosmos DB client instance:
- Get the Cosmos DB account properties:
- Check if default network access is enabled:
- Disable default network access: