Deploy Azure SQL Database programmatically

Jakub Pernica 220 Reputation points
2023-08-28T11:10:51.8933333+00:00

Hello,

I'd like to know what are my options for such scenario:

Let's say I have a multitenant application. I want to onboard new tenants from my admin GUI. Each tenant will needs it's own SQL Database deployed in Azure. After specifying things like tenant name, id, etc. and submitting the process, I want to programmatically deploy an Azure SQL Database (single or possibly in already existing elastic pool), also add some records to the Azure App Configuration (which would already exist).

What would be the best way to achieve that and what are some alternatives? I would most likely have some .NET application for handling the onboarding process.

Thanks!

Azure SQL Database
0 comments No comments
{count} votes

Accepted answer
  1. GeethaThatipatri-MSFT 29,542 Reputation points Microsoft Employee Moderator
    2023-09-01T00:41:07.53+00:00

    Hi @Jakub Pernica

    You might need to look at the Azure Resource Manager SDK for .NET.

     you can find the sample here.

    Samples: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/resourcemanager/Azure.ResourceManager/samples

    Regards

    Geetha

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2023-08-28T13:14:46.61+00:00

    Here you will find a sample multitenant SaaS application using a database per tenant model, built on Azure SQL Database. On the source code and management scripts shared on the URL, you will find that the application creates a catalog database that holds the mapping between tenants and their databases. This mapping is managed using the shard map management features of the Elastic Database Client Library, which also provides efficient connection management to the application. That is the recommended approach on a database per tenant model.

    If you want, the databases can be hosted in elastic pools to provide cost-efficient and easy performance management, which leverages the unpredictable usage patterns of the tenants.

    Here you will find more information about multi-tenant SaaS apps.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.