Created
October 25, 2019 19:57
-
-
Save PCfromDCSnippets/2210bbc9ffaa62522db248170f8cd8f8 to your computer and use it in GitHub Desktop.
Create-VmUserRole
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Run on Master DB **/ | |
/** Change variables to name of VM needing Access to Azure DB **/ | |
DECLARE @vmName1 NVARCHAR(20) = 'AzDO-01' | |
/** Declare query variables **/ | |
DECLARE @query1 NVARCHAR(MAX), | |
@query2 NVARCHAR(MAX) | |
/** Update @vmName1 **/ | |
SET @query1 = CONCAT('CREATE USER [', @vmName1, '] FROM EXTERNAL PROVIDER') | |
SET @query2 = CONCAT('ALTER ROLE [dbmanager] ADD MEMBER [', @vmName1, ']') | |
/** Execute query variables **/ | |
EXEC sp_executesql @query1 | |
EXEC sp_executesql @query2 | |
/** | |
CREATE USER [azdo-app-01] FROM EXTERNAL PROVIDER | |
ALTER ROLE [dbmanager] ADD MEMBER [azdo-app-01] | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment