Edit

Share via


Quickstart: Create a Cosmos DB database in Microsoft Fabric (preview)

Important

This feature is in preview.

In this quickstart, you create a Cosmos DB database using the Microsoft Fabric portal. Once you create the database, you seed the database with a sample container and data set. Then you finish up by querying the sample data set with a sample NoSQL query.

Prerequisites

Create the database

First, go to the Fabric portal and create a new Cosmos DB database within your workspace.

  1. Open the Fabric portal (https://app.fabric.microsoft.com).

  2. Navigate to your target workspace where you want the database to reside.

  3. Select the Create option.

    Screenshot of the option to 'Create' a new resource in the Fabric portal.

  4. If the option to create an Cosmos DB account isn't initially available, select See all.

  5. Within the Databases category, select Cosmos DB (preview).

    Screenshot of the option to specifically create a Cosmos DB database in the Fabric portal.

  6. Give the database a unique name and then select Create.

    Screenshot of the dialog to name a new Cosmos DB database in the Fabric portal.

  7. Wait for the database creation operation to finish before proceeding to the next step[s].

Load sample data

Next, load a sample data set into the database using the tools in the Fabric portal.

  1. Start in the Cosmos DB database within the Fabric portal.

  2. Select Sample data on the Build your database page.

    Screenshot of the option to load sample data into the database using the Fabric portal.

  3. A dialog appears informing you that the import operation could take a few minutes. Select Start to begin importing the sample data set.

    Screenshot of the dialog to confirm that the sample data loading operation could take a few minutes in the Fabric portal.

  4. Wait for the loading operation to finish.

    Screenshot of the dialog to indicate that sample data is loading to the database in the Fabric portal.

  5. Once the import operation concludes, select Close.

    Screenshot of the dialog to indicate that the sample data loading operation succeeded in the Fabric portal.

Perform a query

Finally, perform a NoSQL query to test the sample data in the SampleData container that was created.

  1. Stay within the Cosmos DB database within the Fabric portal.

  2. Select the newly created SampleData container. Then, select New SQL Query.

    Screenshot of the option to create a 'New SQL Query' for a container within the Fabric portal.

  3. In the query editor, use this baseline query to reshape the data in the sample container into simplified JSON output.

    SELECT TOP 10 VALUE {
        "item": CONCAT(item.name, " - ", item.category),
        "price": item.price
    }
    FROM items AS item
    ORDER BY item.price DESC
    
  4. Observe the results of the query in the query editor.

    [
      {
        "item": "Basic Speaker Mini (Black) - Media",
        "price": 1096.74
      },
      {
        "item": "Luxe Keyboard Ultra (Red) - Perhipheral",
        "price": 1091.03
      },
      // Ommitted for brevity
    ]
    

    Screenshot of the query editor and result sections for a container in the Fabric portal.