Tuesday, February 11, 2020

To create a new user for BYOD (Azure SQL database)

Sometimes, when working with Dynamics 365 for Finance and Operations, we go with the option of BYOD (Bring your own database) in order to enable Asynchronous integrations. In such one scenario, I had to create a new db user for the BYOD Azure SQL database and below are the scripts for the same

-- create SQL auth login from master 
CREATE LOGIN test WITH PASSWORD = 'SuperSecret!' 

-- select your db in the dropdown and create a user mapped to a login 
CREATE USER [test] FOR LOGIN [test] WITH DEFAULT_SCHEMA = dbo; 

-- add user to role(s) in db 
ALTER ROLE db_datareader ADD MEMBER [test]; 
ALTER ROLE db_datawriter ADD MEMBER [test]; 

These are the three steps to be performed in order to add new login / user for your BYOD. 
More info in this blog.