Azure Cosmos DB MongoDb Dataset inside an Azure Data Factory

Hi, I seem not to be able to find a Azure Cosmos DB MongoDb Dataset which would work with Azure Cosmos DB (MongoDB API) linked service.

I am creating linked service using azurerm_data_factory_linked_service_cosmosdb_mongoapi resource. The only dataset resource I can find in documentation is the one for Sql API and no the the Mongo Api: azurerm_data_factory_dataset_cosmosdb_sqlapi. Have someone encountered this issue and managed to resolve? Any ideas would be much appreciated.

1 Like

There should be a way to do it manually using the azapi_resource_action resource. I’ll post a snippet if I get one working.

In the meantime, I might submit a feature request via the provider’s GitHub issues.

GitHub issue: Cosmos DB MongoDB-API Data Factory dataset · Issue #27106 · hashicorp/terraform-provider-azurerm · GitHub

Seems to work:

resource "azapi_resource" "source_dataset" {
  name      = "mydb"
  parent_id = "/subscriptions/.../foo"
  type      = "Microsoft.DataFactory/factories/datasets@2018-06-01"

  body = {
    properties = {
      annotations = ["foo:bar"]
      description = "My MongoDB database 'mydb' collection 'mycoll'"
      type        = "CosmosDbMongoDbApiCollection"

      linkedServiceName = {
        referenceName = azurerm_data_factory_linked_service_cosmosdb_mongoapi.source.name
        type          = "LinkedServiceReference"
      }

      typeProperties = {
        collection = "mycoll"
      }
    }
  }
}