簡體   English   中英

如何將變量傳遞給 azure devops 管道中的 SqlAzureDacpacDeployment@1 任務

[英]How can I pass a variable to the SqlAzureDacpacDeployment@1 task in azure devops pipeline

我正在嘗試讓應用程序訪問數據庫。 其中一個步驟要求必須在數據庫上運行創建用戶的腳本。 我通過 azureSqlAzureDacpacDeployment@1 任務的管道執行此操作。

使用托管標識從應用服務保護 Azure SQL 數據庫連接

- 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-

您似乎正在嘗試在 SQL 腳本中定義變量。 您可以嘗試DECLARE語句和SET語句,如下鏈接所示:

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/variables-transact-sql?view=sql-server-ver15

-- Declare two variables.
DECLARE @AppName nvarchar(50);

-- Set their values.
SET @AppName = 'MyApplication';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM