8

I am trying to create users inside DB and grant some specific permission each user; with the help of ARM template. But I do not find a way to do it using ARM.

Can someone tell me is it supported by the ARM templates to

  1. Create Users for DB and grant permissions?
  2. does it support to deploy a Dacpac to DB?
Pavan
  • 1,023
  • 2
  • 12
  • 25

1 Answers1

8

You can't insert users into a database using an ARM template to my knowledge. I've looked pretty closely - someone correct me if I'm wrong.

As for the ability to get data into the system, you have some options with VSTS Build.

  1. You can use a Powershell task to call invoke_sqlcmd, which you can insert users using your own script.

  2. My personal favorite is the Azure SQL Database deployment task, which will deploy a DACPAC. In the DACPAC you can set up users as needed.

Rob Reagan
  • 7,313
  • 3
  • 20
  • 49
  • Correct, currently there isn't a way to run a SQL script against an Azure SQL Database from an ARM template. If only there were a Custom Script Extension for Azure SQL Database... – Chris Pietschmann May 25 '17 at 17:10
  • @ChrisPietschmann, don't hold out on me! Have you written such a script? – Rob Reagan May 25 '17 at 17:32
  • @RobReagan, I am already doing the DACPAC Approach; as you said in point no.2. But deploying DACPAC itself is not supported using ARM template as of now (though it supports BACPAC, I read in many articles). So for now I am crating DB server and instance using ARM templates and creation of users is set up in DACPAC, which is deployed using powershell commands – Pavan May 26 '17 at 05:19
  • My goal was to perform all these by using ARM templates only. – Pavan May 26 '17 at 05:24
  • 1
    @RobReagan LOL I had a ARM Template I built once that included a VM and Azure SQL Database among other things. In that case, I setup a Custom Script extension on the VM that went and ran a SQL Script against the Azure SQL Database. – Chris Pietschmann May 26 '17 at 22:54