Is it possible to run a sql script while creating database from ARM Template

Nishant Jain 1 Reputation point
2022-07-07T11:09:06.683+00:00

Hello,

We are trying to create a sql database in azure using Azure Resource Group from Tempate using visual studio. We want to run a sql script after the creation of database so that the tables are created in database at run time only. Is there any way avaiable ??

Any help would be appricated.

Thanks!

Azure DevTest Labs
Azure DevTest Labs
An Azure service that is used for provisioning development and test environments.
260 questions
Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
736 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anurag Sharma 17,581 Reputation points
    2022-07-11T05:35:32.16+00:00

    Hi @Nishant Jain , welcome to Microsoft Q&A forum.

    As I understand you want to deploy the schema of database at the time of server creation.

    We can do it with the help of importing bacpac files with ARM templates. Firstly we need to create the bacpac file and then use the url of it in ARM template. Please refer to below article that has the details related to it:

    Import SQL BACPAC files with ARM templates

    Please refer to completed template and let us know if you face any issue or have any other queries.

    0 comments No comments