Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “Restrict Default Network Access for Azure Cosmos DB Accounts” in Azure using the Azure console, follow these steps:
  1. Log in to the Azure portal (https://portal.azure.com/).
  2. Navigate to the Azure Cosmos DB account for which you want to restrict network access.
  3. Click on the “Firewalls and virtual networks” tab.
  4. Under the “Firewall” section, select “Enabled”.
  5. Under the “Virtual networks” section, select the virtual network that you want to allow access to.
  6. Under the “Subnets” section, select the subnet that you want to allow access to.
  7. Click on “Save” to apply the changes.
By following these steps, you have successfully remediated the misconfiguration “Restrict Default Network Access for Azure Cosmos DB Accounts” in Azure using the Azure console.

To remediate the misconfiguration “Restrict Default Network Access for Azure Cosmos DB Accounts” in Azure using Azure CLI, follow the below steps:
  1. Open the Azure CLI on your local machine or use the Azure Cloud Shell.
  2. Login to your Azure account using the command az login.
  3. Once logged in, select the subscription you want to work with using the command az account set --subscription <subscription_id>.
  4. Get the list of Cosmos DB accounts in the selected subscription using the command az cosmosdb list.
  5. Choose the Cosmos DB account for which you want to restrict default network access.
  6. Run the following command to update the Cosmos DB account settings to restrict default network access:
Note: Replace the placeholders <cosmos_db_account_name>, <resource_group_name>, <consistency_level>, <region_name>, and <subscription_id> with the actual values.
  1. Once the command is executed successfully, the default network access for the Cosmos DB account will be restricted.
This will remediate the misconfiguration “Restrict Default Network Access for Azure Cosmos DB Accounts” in Azure using Azure CLI.
To restrict default network access for Azure Cosmos DB Accounts using Python, you can follow these steps:
  1. Import the necessary modules:
  1. Create a Cosmos DB client instance:
  1. Get the Cosmos DB account properties:
  1. Check if default network access is enabled:
  1. Disable default network access:
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.
If you need connectivity after this change, configure a private endpoint (azurerm_private_endpoint) for the server in a secure virtual network.Verification: terraform plan should show an update to the existing azurerm_mssql_server setting public_network_access_enabled changing from true (or null) to false.