I am trying to give an application access to a database. One of the steps require that a script that create a user must be run on the database. I am doing this through the pipeline with azureSqlAzureDacpacDeployment@1 task.
Secure Azure SQL Database connection from App Service using a managed identity
- task: SqlAzureDacpacDeployment@1
inputs:
azureSubscription: 'xxxxxxxx (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)'
AuthenticationType: 'aadAuthenticationIntegrated'
ServerName: '$(SqlServerName)'
DatabaseName: '$(SqlDatabaseName)'
deployType: 'InlineSqlTask'
SqlInline: |
CREATE USER [$(AppName)] FROM EXTERNAL PROVIDER;
ALTER ROLE db_datareader ADD MEMBER [$(AppName)];
ALTER ROLE db_datawriter ADD MEMBER [$(AppName)];
GO
InlineAdditionalArguments: '-v $(ApiAppName)'
IpDetectionMethod: 'AutoDetect'
ApiAppName = 'AppName=MyApplication'
##[error]The format used to define the new variable for Invoke-Sqlcmd cmdlet is invalid.
Please use the 'var=value' format for defining a new variable.Check out how to troubleshoot
failures at https://aka.ms/sqlazuredeployreadme#troubleshooting-