From the error message in your comment,
Can not parse "virtual_network_rule.0.id" as a resource id: Cannot
parse Azure ID: parse "APSG-APP1": invalid URI for request on main.tf
line 16, in resource "azurerm_cosmosdb_account" "db": 16: resource
"azurerm_cosmosdb_account" "db" {
I can reproduce this issue. It might be a problem with your subnet ID. Please check the subnet id you have passed to the terraform code. The id
should be a resource id of the subnet instead of a subnet name.
virtual_network_rule {
id = "/subscriptions/xxxx/resourceGroups/xxxrg/providers/Microsoft.Network/virtualNetworks/xxxxvnet/subnets/xxxSubnet"
}
If you're trying to add an existing subnet, the subnet should enable the service endpoint for Microsoft.AzureCosmosDB
.
service_endpoints = ["Microsoft.AzureCosmosDB"]
Or you can add ignore_missing_vnet_service_endpoint
to ignore missing service endpoint.