Dracon
Dracon

Reputation: 81

Azure CosmosDB copy DB Stored Procedure

I have 2 databases, a prod and a test. I want to write a stored procedure to empty test, and populate it with items from prod. Prod isnt huge, ~2k items.

If this is better achieved without a stored procedure, im also open to that :)

Can anyone point me to any resources around this? I am currently using the bulk import base procedure, but I cant figure out how to access another db's items within that.

Upvotes: 2

Views: 804

Answers (1)

suziki
suziki

Reputation: 14088

1, Use Azure Datafactory. Create a pipeline and use copy activity to copy. Set your test database as the source and the prod database as the sink.

2, Use Azure Function, then use binding or just put the code in the body of function.

https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2

3, Use CosmosDB Data migration tool.

This is the doc:

https://learn.microsoft.com/en-us/azure/cosmos-db/import-data

For example, If use Azure Datafactory to achieve your requirement, you can follow below steps:

First of all you need to create a datafactory on azure.

Step 1: Create pipeline:

enter image description here

Step 2: Create a copy activity:

enter image description here

Step 3: Click the copy activity, create the dataset:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Above is how to create source dataset, create sink dataset is similar.

Step 4: Then Just Click Debug:

enter image description here

Upvotes: 1

Related Questions