"Model" Database Eqivilent for Azure SQL as a Service

Michael Howard 21 Reputation points
2021-03-04T09:46:47.62+00:00

I am looking to mirror Automated Permissions, that have been set up on an SQL Server that runs on windows server locally, that will automatically assign permissions to users/groups when a database is created.

On the Local SQL this was done using the below SQL script to add the desired permissions to the model database.

USE model;
GO

IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'Domain\Group')
    BEGIN
        CREATE USER [Domain\Group] FOR LOGIN [Domain\Group]
    END
GO

ALTER ROLE db_datawriter ADD MEMBER [Domain\Group];
ALTER ROLE db_datareader ADD MEMBER [Domain\Group];
GO

However, as there is no "model" database in AzureSQL is there an alterative method for this native to azure , or should we look to automate via other tooling (Such as Terraform or incorporating into the DACPAC project we use to deploy)

Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,756 questions
{count} votes

Accepted answer
  1. Dan Guzman 9,211 Reputation points
    2021-03-04T10:52:19.38+00:00

    I suggest you include the script as part of your deployment process and avoid using model even for local SQL instances. Tooling, such as SSDT and source control, can facilitate consistent deployment of both schema and permissions.

    0 comments No comments

0 additional answers

Sort by: Most helpful