Deleting documents from Mongo API Collection on Azure Cosmos DB

Gana VK 21 Reputation points
2020-09-30T22:20:35.98+00:00

We have a Mongo API Collection implemented on Azure Cosmos DB. I am presently creating a pipeline in Azure Data Factory to implement the following process.

  1. Delete all the existing documents in the target Mongo API Collection on Azure Cosmos DB
  2. Read the CSV delimited data stored on Blob data storage.
  3. Construct a complex JSON document from the flat row read from source
  4. Insert the documents to target Mongo API Collection.

Two questions

  • Is it possible to construct complex JSON document ( step 2) using the COPY activity ? I was not and so used dataflow to create one.
  • How do I delete Mongo DB collection ? Is there an activity available for it ? Any example ?

Thanks Ganapathy

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,632 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,681 questions
0 comments No comments
{count} votes

Accepted answer
  1. KranthiPakala-MSFT 46,487 Reputation points Microsoft Employee
    2020-10-02T04:46:39.883+00:00

    Hi @Gana VK ,

    Welcome to Microsoft Q&A platform and thanks for your query.

    1. Is it possible to construct complex JSON document ( step 2) using the COPY activity ? I was not and so used dataflow to create one.
      Unfortunately Copy activity is not suitable to construct complex JSON documents. Mapping Data flow is the suggested approach by product team for dealing with complex JSON documents.
    2. How do I delete Mongo DB collection ? Is there an activity available for it ? Any example ?
      If it is a one time action, I would recommend to see below powershell and Azure CLI options.
      a) https://video2.skills-academy.com/powershell/module/az.cosmosdb/remove-azcosmosdbmongodbcollection?view=azps-4.7.0
      b) https://video2.skills-academy.com/cli/azure/cosmosdb/mongodb/collection?view=azure-cli-latest#az_cosmosdb_mongodb_collection_delete
      c) In ADF we do not have specific activity, but you can write you own powershell script and execute it using Custom activity.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.