azureazure-sql-databaseazure-elasticpoolazure-elastic-scale

Azure SQL Server Elastic Pool - automatically add database to pool


Currently we have an Azure SQL Server and each time we create new web app, we use EF Core Code First to generate the database. However after the database is created we manually go to Azure portal and add the newly created database to the Elastic Pool inside the Azure SQL Server. Is it possible to somehow automate the process so that each newly created database either via portal or generated using EF or whatever, it will be automatically added to the Pool?


Solution

  • You can use Transact-SQL to programmatically move an existing Azure SQL Database into an elastic pool.

    ALTER DATABASE db1   
    MODIFY ( SERVICE_OBJECTIVE = ELASTIC_POOL ( name = pool1 ) ) ;