Redaguoti

Bendrinti naudojant


Get started with Elastic Database Tools

Applies to: Azure SQL Database

This document introduces you to the developer experience for the elastic database client library by helping you run a sample app. The sample app creates a simple sharded application and explores key capabilities of the Elastic Database Tools feature of Azure SQL Database. It focuses on use cases for shard map management, data-dependent routing, and multi-shard querying. The client library is available for .NET as well as Java.

Elastic Database Tools for Java

Prerequisites

  • A Java Developer Kit (JDK), version 1.8 or later
  • Maven
  • SQL Database or a local SQL Server instance

Download and run the sample app

To build the JAR files and get started with the sample project, do the following:

  1. Clone the GitHub repository containing the client library, along with the sample app.

  2. Edit the ./sample/src/main/resources/resource.properties file to set the following:

    • TEST_CONN_USER
    • TEST_CONN_PASSWORD
    • TEST_CONN_SERVER_NAME
  3. To build the sample project, in the ./sample directory, run the following command:

    mvn install
    
  4. To start the sample project, in the ./sample directory, run the following command:

    mvn -q exec:java "-Dexec.mainClass=com.microsoft.azure.elasticdb.samples.elasticscalestarterkit.Program"
    
  5. To learn more about the client library capabilities, experiment with the various options. Feel free to explore the code to learn about the sample app implementation.

    Progress-java

Congratulations! You have successfully built and run your first sharded application by using Elastic Database Tools on Azure SQL Database. Use Visual Studio or SQL Server Management Studio to connect to your database and take a quick look at the shards that the sample created. You will notice new sample shard databases and a shard map manager database that the sample has created.

To add the client library to your own Maven project, add the following dependency in your POM file:

<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>elastic-db-tools</artifactId>
    <version>1.0.0</version>
</dependency>

Elastic Database Tools for .NET

Prerequisites

Download and run the sample app

To install the library, go to Microsoft.Azure.SqlDatabase.ElasticScale.Client. The library is installed with the sample app that's described in the following section.

To download and run the sample, follow these steps:

  1. Download the Elastic DB Tools for Azure SQL - Getting Started sample. Unzip the sample to a location that you choose.

  2. To create a project, open the ElasticDatabaseTools.sln solution from the elastic-db-tools-master directory.

  3. Set the ElasticScaleStarterKit project as the Startup Project.

  4. In the ElasticScaleStarterKit project, open the App.config file. Then follow the instructions in the file to add your server name and your sign in information (username and password).

  5. Build and run the application. When you are prompted, enable Visual Studio to restore the NuGet packages of the solution. This action downloads the latest version of the elastic database client library from NuGet.

  6. To learn more about the client library capabilities, experiment with the various options. Note the steps that the application takes in the console output, and feel free to explore the code behind the scenes.

    Progress

Congratulations! You have successfully built and run your first sharded application by using Elastic Database Tools on SQL Database. Use Visual Studio or SQL Server Management Studio to connect to your database and take a quick look at the shards that the sample created. You will notice new sample shard databases and a shard map manager database that the sample has created.

Important

We recommend that you always use the latest version of Management Studio so that you stay synchronized with updates to Azure and SQL Database. Update SQL Server Management Studio.

Key pieces of the code sample

  • Managing shards and shard maps: The code illustrates how to work with shards, ranges, and mappings in the ShardManagementUtils.cs file. For more information, see Scale out databases with the shard map manager.

  • Data-dependent routing: Routing of transactions to the right shard is shown in the DataDependentRoutingSample.cs file. For more information, see Data-dependent routing.

  • Querying over multiple shards: Querying across shards is illustrated in the MultiShardQuerySample.cs file. For more information, see Multi-shard querying.

  • Adding empty shards: The iterative adding of new empty shards is performed by the code in the CreateShardSample.cs file. For more information, see Scale out databases with the shard map manager.

Other elastic scale operations

Cost

The Elastic Database Tools library is free. When you use Elastic Database Tools, you incur no additional charges beyond the cost of your Azure usage.

For example, the sample application creates new databases. The cost of this capability depends on the SQL Database edition you choose and the Azure usage of your application.

For pricing information, see SQL Database pricing details.

Next steps

For more information about Elastic Database Tools, see the following articles: