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.
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:
ADMIN_LOGIN="ServerAdmin" RESOURCE_GROUP=<rgn>[sandbox resource group name]</rgn> SERVERNAME=FitnessSQLServer-$RANDOM LOCATION=<location> PASSWORD=<password>
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
Add a database named FitnessVancouverDB to FitnessSQLServer-nnnn.
az sql db create \ --resource-group $RESOURCE_GROUP \ --server $SERVERNAME \ --name FitnessVancouverDB
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.
Sign into the Azure portal using the same account you used to activate the sandbox.
From the Azure portal menu or the Home page, select Create a resource. Search for and select SQL Elastic database pool.
Select the SQL Elastic database pool result and then press the Create button on the next screen.
Give your new elastic pool a meaningful name such as FitnessSQLPool, and ensure the
[sandbox resource group name]resource group is selected.
In the Server section, ensure your existing FitnessSQLServer-nnnn server is selected
In the Compute + storage section, click Configure elastic pool.
Click Basic, and then click Apply.
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
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.
Select Configure in the Settings section.
Select the Databases tab.
Click + Add databases.
Select the databases for both locations.
Congratulations, you've successfully added databases to a SQL elastic pool.