azurecassandraazure-cosmosdbazure-rm-templateazure-cosmosdb-cassandra-api

How to define PRIMARY KEY in azure cosmosdb arm template


is it possible to define PRIMARY key in azure cosmosdb cassandra arm template ?

Let's say I have next table:

CREATE TABLE foo
(
 id text
 name test
 PRIMARY KEY (id)
)

And my ARM template:

"schema":{
 "columns":[
   {
   "name":"id",
   "type":"text"
   }   
  ],
  "partitionKeys":[
    {"name":"id"} // how to define primary key ?
 }

Solution

  • Primary key in Cassandra consists of one or more partition columns, and zero or more clustering columns. In ARM templates they are defined as partitionKeys and clusterKeys arrays of objects. Here is the example from documentation:

    "partitionKeys": [
        { "name": "machine" },
        { "name": "cpu" },
        { "name": "mtime" }
    ],
    "clusterKeys": [
        {
          "name": "loadid",
          "orderBy": "asc"
        }
    ]