An end to end demonstration of Cloud-native hybrid transactional and analytical processing (HTAP) capability that enables near real time analytics over operational data in Azure Cosmos DB using Azure Synapse Link for Cosmos DB.
Synapse Link for Cosmos DB automatically syncs data between the Transaction store and Analytical store. The analytical store data can be processed using SQL Serverless or Spark runtime, thus making the analytical workload cost effective and independent of the transactional compute resources.
-
Create a database called "ContosoMobile" with 4000 RU as Throughput.
-
Create a collection called "CallRecords" with '/pk' as PartitionKey.
-
Create a collection called "Bills" with '/id' as PartitionKey.
The below steps will create an Azure Synapse workspace using the Azure portal.
-
Open the Azure portal, and at the top search for Synapse.
-
In the search results, under Services, select Azure Synapse Analytics.
-
Select Add to create a workspace.
-
In the Basics tab, give the workspace a unique name. We'll use mysworkspace in this document
-
You need an ADLSGEN2 account to create a workspace. The simplest choice is to create a new one.
- Under Select Data Lake Storage Gen 2, click Create New and name it contosolake.
- Under Select Data Lake Storage Gen 2, click File System and name it contosofs.
-
Select Review + create > Create. Your workspace will be ready in a few minutes.
After your Azure Synapse workspace is created, you have two ways to open Synapse Studio:
- Open your Synapse workspace in the Azure portal. On the top of the Overview section, select Launch Synapse Studio.
- Go to the https://web.azuresynapse.net and sign in to your workspace.
Refer to Connect an Azure Cosmos DB database to a Synapse workspace
Refer to Enable Synapse Link in your Cosmos DB SQL API or MongoDB API account using Azure CLI or PowerShell.
Note: If you can enable Synapse link via the Azure portal you will not be able to set analytical storage to FullFidelity. Therefore, we will enable Synapse Link and set schema using CLI.
Replace the {Cosmos Account Name} placeholder with your own value and run the below command to enable Synapse link on your Cosmos DB Account.
az cosmosdb update --name {Cosmos Account Name} --analytical-storage-schema-type FullFidelity --enable-analytical-storage true
-
In Synapse Studio, Open the Develop Blade
-
Click on the "+" icon and then select Import.
-
Browse and locate the Spark Notebook and SQL View files.
- Download or clone this repo and open the "Call Logger Application\CallLog" folder in VS code.
- Edit appsettings.json to replace the {Cosmos Account Name} and {Cosmos PRIMARY Key} placeholders with your own value.
- Build the application
- Execute the CallLogger.exe from command prompt to generate fake call logs and populate the CallRecords collection in Cosmos DB.
- Optionally pass command line arguments to modify fake data pattern.
CallLogger.exe offset=90 count=100 caller=091-945-123-0008
-
Open the CreateView SQL file from the Develop tab in Synapse Studio.
-
Update the {Cosmos Account Name} and {Cosmos PRIMARY Key} placeholders.
-
Execute the scripts to create the SQL View. Follow the instructions provided as comments.
-
To connect to the SQl Serverless, get the connection details from the Synapse workspace Overview tab.
- Generate the password using Reset SQL admin password link.
- Use Severless SQL endpoint value as the Server Name
- Use SQL admin username value as the User Name
- Open the GenerateBill Spark Notebook from the Develop tab in Synapse Studio.
- Execute the scripts in sequence. Follow the instructions provided.