我正在尝试授予应用程序对数据库的访问权限。其中一个步骤要求必须在数据库上运行用于创建用户的脚本。我正在使用azureSqlAzureDacpacDeployment @ 1任务通过管道进行此操作。
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-
答案 0 :(得分:0)
似乎您正在尝试在SQL脚本中定义变量。您可以按照以下链接状态尝试使用DECLARE
语句和SET
语句:
-- Declare two variables.
DECLARE @AppName nvarchar(50);
-- Set their values.
SET @AppName = 'MyApplication';