Share via

can i create database in cosmos from code written by c# only using sql syntax? meaning this "create database databaseName"

jha jshs 1 Reputation point
2022-05-17T19:06:39.12+00:00

i tried doing so with cosmos client/ documentclient with no success.
thank you very much

Azure Cosmos DB
Azure Cosmos DB

An Azure NoSQL database service for app development.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Mark Brown - MSFT 2,771 Reputation points Microsoft Employee Moderator
    2022-05-17T19:30:46.507+00:00

    There are 2 options to create database and container resources using C#.

    The first is our data plane SDKs. Here are examples, CosmosClient.CreateDatabaseIfNotExistsAsync and Database.CreateContainerIfNotExistsAsync

    The second method is to use the Azure Management SDK for .NET. Here are examples for that, CreateDatabaseAsync and CreateContainerAsync The nuget package for that is here, https://www.nuget.org/packages/Microsoft.Azure.Management.CosmosDB. Note this is in Preview.

    Was this answer helpful?

    1 person found this answer helpful.

Your answer

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