01 Run account list command (Windows/macOS/Linux) with custom output filters to list the IDs of the cloud subscriptions available in your Azure cloud account:
az account list
--query '[*].id'
02 The command output should return the requested subscription identifiers (IDs):
[
"abcdabcd-1234-abcd-1234-abcdabcdabcd",
"abcd1234-abcd-1234-abcd-abcd1234abcd"
]
03 Run account set command (Windows/macOS/Linux) with the ID of the Azure cloud subscription that you want to access as the identifier parameter to set the selected subscription to be the current active subscription (the command does not produce an output):
az account set
--subscription abcdabcd-1234-abcd-1234-abcdabcdabcd
04 Run cosmosdb update command (Windows/macOS/Linux) to enable virtual network (VNet) integration for the selected Azure Cosmos DB account:
az cosmosdb update
--ids "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.DocumentDB/databaseAccounts/cc-project5-cosmos-database"
--enable-virtual-network true
05 The command output should return the information available for the modified Azure Cosmos DB account:
{
"analyticalStorageConfiguration": {
"schemaType": "WellDefined"
},
"backupPolicy": {
"migrationState": null,
"periodicModeProperties": {
"backupIntervalInMinutes": 240,
"backupRetentionIntervalInHours": 8,
"backupStorageRedundancy": "Local"
}
},
...
"capabilities": [],
"capacity": {
"totalThroughputLimit": 1000
},
"connectorOffer": null,
"consistencyPolicy": {
"defaultConsistencyLevel": "Session",
"maxIntervalInSeconds": 5,
"maxStalenessPrefix": 100
}
}
06 Run cosmosdb network-rule add command (Windows/macOS/Linux) to create and attach a virtual network (VNet) rule to your Azure Cosmos DB account. The rule contains the virtual network and subnet that you want to use for VNet integration with your DB account:
az cosmosdb network-rule add
--ids "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.DocumentDB/databaseAccounts/cc-project5-cosmos-database"
--name "cc-project5-vnet-rule"
--virtual-network "cc-project5-vnet"
--subnet "cc-vnet-subnet-001"
07 The command output should return the information for the modified Cosmos DB account:
{
"analyticalStorageConfiguration": {
"schemaType": "WellDefined"
},
"apiProperties": null,
"backupPolicy": {
"migrationState": null,
"periodicModeProperties": {
"backupIntervalInMinutes": 240,
"backupRetentionIntervalInHours": 8,
"backupStorageRedundancy": "Local"
}
},
...
"type": "Microsoft.DocumentDB/databaseAccounts",
"virtualNetworkRules": [
{
"id": "/subscriptions/abcdabcd-1234-abcd-1234-abcdabcdabcd/resourceGroups/cloud-shell-storage-westeurope/providers/Microsoft.Network/virtualNetworks/cc-project5-vnet/subnets/cc-vnet-subnet-001",
"ignoreMissingVnetServiceEndpoint": false,
"resourceGroup": "cloud-shell-storage-westeurope"
}
]
}
08 Repeat steps no. 4 - 7 for each Azure Cosmos DB account that you want to configure, available within the selected subscription.
09 Repeat steps no. 3 – 8 for each Azure subscription created in your Microsoft Azure cloud account.