Exercise - Create a SQL elastic pool

In this exercise, we'll create two Azure SQL databases to represent two fitness locations, and then create a SQL elastic pool to manage two databases.

Create SQL servers

We'll start by creating a SQL server for our fitness databases and we'll add databases for two locations. The steps use Vancouver and Paris but feel free to use other location names.

  1. First declare a few helper variables. SERVERNAME variable will have a random number after the '-'. Replace <location> with one of the locations in the list below and replace <password> with a complex password for the databases.

    The free sandbox allows you to create resources in a subset of the Azure global regions. Select a region from this list when you create resources:

    • westus2
    • southcentralus
    • centralus
    • eastus
    • westeurope
    • southeastasia
    • japaneast
    • brazilsouth
    • australiasoutheast
    • centralindia
    RESOURCE_GROUP=<rgn>[sandbox resource group name]</rgn>
  2. Create a server named FitnessSQLServer-nnnn.

    az sql server create \
    --name $SERVERNAME \
    --resource-group $RESOURCE_GROUP \
    --location $LOCATION \
    --admin-user $ADMIN_LOGIN \
    --admin-password $PASSWORD
  3. Add a database named FitnessVancouverDB to FitnessSQLServer-nnnn.

    az sql db create \
    --resource-group $RESOURCE_GROUP \
    --server $SERVERNAME \
    --name FitnessVancouverDB
  4. Add a database named FitnessParisDB to FitnessSQLServer-nnnn.

    az sql db create \
    --resource-group $RESOURCE_GROUP \
    --server $SERVERNAME \
    --name FitnessParisDB

Create a SQL elastic pool

We're ready to set up the resources for the SQL elastic pool. We'll switch to the portal to create the elastic pool.

  1. Sign into the Azure portal using the same account you used to activate the sandbox.

  2. From the Azure portal menu or the Home page, select Create a resource. Search for and select SQL Elastic database pool.

  3. Select the SQL Elastic database pool result and then press the Create button on the next screen.

  4. Give your new elastic pool a meaningful name such as FitnessSQLPool, and ensure the [sandbox resource group name] resource group is selected.

  5. In the Server section, ensure your existing FitnessSQLServer-nnnn server is selected

  6. In the Compute + storage section, click Configure elastic pool.

  7. Click Basic, and then click Apply.

  8. Click Review + create. Review your information, and then click Create. The SQL elastic pool may take several minutes to provision.

Add existing databases to the elastic pool

  1. Open your newly created SQL elastic pool in the Azure portal and navigate to the Overview section. Note there are currently no databases in the pool.

  2. Select Configure in the Settings section.

  3. Select the Databases tab.

  4. Click + Add databases.

  5. Select the databases for both locations.

  6. Click Apply.

  7. Click Save.

Congratulations, you've successfully added databases to a SQL elastic pool.