- Log in to the Azure portal at https://portal.azure.com. Click the menu button in the top‐left corner of the main page, and click + Create A Resource. Select Databases and click Azure Cosmos DB. Then, click the Create button under (Core) SQL, as shown in Figure 2.6.
FIGURE 2.6 Azure Cosmos DB APIs
- Select the subscription and resource group where you want to place the Azure Cosmos DB. Enter an account name (I used csharpguitar) and select a location. Select the Serverless Capacity mode. Leave all other default settings and click the Review + Create button and then the Create button.
- After the provision is complete, navigate to the resource and from the Features menu select Azure Synapse Link and click Enable.
- Navigate to the Overview blade of the Azure Cosmos DB. Click + Add Container, add a database ID (I used brainjammer), add a container ID (I used sessions), and change the partition key (I used /pk). Click the On radio button for Analytical Store and click OK.
- Navigate to the folder Chapter02/Ch02Ex02/brainjammer‐cosmos at https://github.com/benperk/ADE to check out some C# code that you can use to upload a JSON file to the database and container. There are also two JSON files that you can use.
- Choose Data Explorer from the Azure Cosmos DB navigation menu and expand the database (in my example, brainjammer). Expand the container ID (in my example, sessions), then click Items. You will see the contents of the file you selected, similar to Figure 2.7. Notice that there is also an Upload Item button where you can click to manually upload one of the provided JSON files.
FIGURE 2.7 Azure Cosmos Data Explorer
- Try running a few queries; the output of the first is shown in Figure 2.8.
SELECT sessions.Session.Scenario FROM sessions
SELECT s.pk, s.Session.POWReading[0]
FROM sessions s
WHERE s.pk = “MetalMusic”
FIGURE 2.8 Azure Cosmos Data Explorer SQL query
The first query returns the scenario from all the files in that container. The second query returns the first reading for a specific scenario.