# Error in creating a virtual graph with Azure Cosmos DB

**URL:** <https://community.stardog.com/t/error-in-creating-a-virtual-graph-with-azure-cosmos-db/3131>\
**Category:** Support\
**Created:** [July 9, 2021, 10:19am UTC](https://community.stardog.com/t/error-in-creating-a-virtual-graph-with-azure-cosmos-db/3131 "2021-07-09T10:19:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Sam](https://community.stardog.com/u/Sam)\
**Post date:** [July 9, 2021, 10:19am UTC](https://community.stardog.com/t/error-in-creating-a-virtual-graph-with-azure-cosmos-db/3131/1 "2021-07-09T10:19:39Z")

</div>

Hi All,

I'm new to stardog. Getting irrelevant error of "SMS2 mappings for rel databases must use sql sources(Bad request)" when tried to create a virtual graph with azure cosmos db mongo api.

Tried creating a virtual graph with MySQL and mongo db and able to create it .

the same mapping i have used for virtualizing mongodb and it worked.

Trying to create a virtual graph by connecting with Azure CosmosDB Mongo API through stardog studio.

In Data Sources , the connection is created.

Populated the same sample movie json data provided for mongo db virtual graphs from documentation into the azure cosmos db mongo api .

Given a sms mapping file provided in documentation ([Mapping Data Sources | Stardog Documentation Latest](https://docs.stardog.com/virtual-graphs/mapping-data-sources)) - but while creating a virtual graph from stardog studio.

Receiving the below error :

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/9/9c275c98323220a0cbfc634fd3f4c69d3d1b226d.png)

Used configs :

Database name : movies

Collection name : movies

Data source config :  
jdbc.url = jdbc:cosmosdb:AccountEndpoint=[host.cosmos.azure.com:10255](http://host.cosmos.azure.com:10255);AccountKey=\*\*\*\*\*\*

sms mapping :  
PREFIX : [http://stardog.com/movies/](http://stardog.com/movies/)  
MAPPING urn:movies  
FROM JSON {  
"movies":{  
"\_id":"?movieId",  
"name":"?name",  
"datePublished":"?datePublished",  
"genre":["?genre"],  
"boxOffice":"?boxOffice",  
"description":"?description",  
"director":[ {  
"director":"?directorId",  
"name":"?directorName"  
}  
],  
"actor":[ {  
"actor":"?actorId",  
"name":"?actorName"  
}  
]  
}  
}  
TO {  
?movie a :Movie ;  
:name ?name ;  
:datePublished ?xsdDatePublished ;  
:genre ?genre ;  
:boxOffice "?boxOffice"^^xsd:integer ;  
:description ?description ;  
:directed ?directedMovie ;  
:actedIn ?actedInMovie .

?directedMovie a :DirectedMovie ;  
:director ?director ;  
:name ?directorName .

?director a :Person .

?actedInMovie a :ActedInMovie ;  
:actor ?actor ;  
:name ?actorName .

?actor a :Person .  
}  
WHERE {  
//removed other bindings due to link constraint while creating a post //  
BIND (xsd:date(?datePublished) AS ?xsdDatePublished)  
}

**data in cosmos db** :  
{  
"\_id":"unforgiven",  
"name":"Unforgiven",  
"datePublished":new Date("1992-08-07T00:00:00.000Z"),  
"genre":["Drama", "Western"],  
"boxOffice":101157447,  
"description":"Retired gunslinger reluctantly takes on one last job.",  
"director":[  
{"director":"clintEastwood", "name":"Clint Eastwood"}  
],  
"actor":[  
{"actor":"morganFreeman", "name":"Morgan Freeman"},  
{"actor":"clintEastwood", "name":"Clint Eastwood"},  
{"actor":"geneHackman", "name":"Gene Hackman"}  
]  
}  
{  
"\_id":"noWayOut",  
"name":"No Way Out",  
"datePublished":new Date("1987-08-14T00:00:00.000Z"),  
"genre":["Action", "Mystery", "Drama", "Thriller"],  
"boxOffice":35509515,  
"description":"A coverup and witchhunt occur after a politician accidentally kills his mistress.",  
"director":[  
{"director":"rogerDonaldson", "name":"Roger Donaldson"}  
],  
"actor":[  
{"actor":"geneHackman", "name":"Gene Hackman"},  
{"actor":"kevinCostner", "name":"Kevin Costner"}  
]  
}

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [July 9, 2021, 4:19pm UTC](https://community.stardog.com/t/error-in-creating-a-virtual-graph-with-azure-cosmos-db/3131/2 "2021-07-09T16:19:51Z")

</div>

Hi Sam,

Thanks for the question. You should be creating a connection to CosmosDB using the MongoDB dialog, not SQL/JDBC. Can you try this and let us know if it works?

Jess

---

<div class="post-metadata">

**Author:** ![Sam](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@Sam](https://community.stardog.com/u/Sam)\
**Post date:** [July 10, 2021, 6:41am UTC](https://community.stardog.com/t/error-in-creating-a-virtual-graph-with-azure-cosmos-db/3131/3 "2021-07-10T06:41:58Z")

</div>

> [@jess](#):
>
> MongoDB dialog,

Thank you very much jess. Your suggestion worked .

Could you please tell us , which of the api's (SQL, Gremlin, Cassandra) in Azure Cosmos DB work with Azure Cosmos DB connector in stardog?

Does only SQL API of Azure cosmos DB work with Azure Cosmos DB connector of stardog ?

---

<div class="post-metadata">

**Author:** ![jess](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/jess/32/10_2.png) [@jess](https://community.stardog.com/u/jess)\
**Post date:** [July 12, 2021, 10:24pm UTC](https://community.stardog.com/t/error-in-creating-a-virtual-graph-with-azure-cosmos-db/3131/4 "2021-07-12T22:24:12Z")

</div>

We have only tested Cosmos DB using the MongoDB API. You could perhaps try [CDATA's Cosmos DB JDBC Driver](https://www.cdata.com/drivers/cosmosdb/jdbc/).

Jess

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [July 26, 2021, 10:24pm UTC](https://community.stardog.com/t/error-in-creating-a-virtual-graph-with-azure-cosmos-db/3131/5 "2021-07-26T22:24:41Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
