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-
It seems you are trying to define variables in SQL Script. You may try DECLARE
statement and SET
statement as the following link states:
-- Declare two variables.
DECLARE @AppName nvarchar(50);
-- Set their values.
SET @AppName = 'MyApplication';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.