gpt4 book ai didi

azure - 如何将变量传递给 azure devops 管道中的 SqlAzureDacpacDeployment@1 任务

转载 作者:行者123 更新时间:2023-12-02 22:53:06 24 4
gpt4 key购买 nike

我正在尝试授予应用程序访问数据库的权限。其中一个步骤要求必须在数据库上运行创建用户的脚本。我通过 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-

最佳答案

您似乎正在尝试在 SQL 脚本中定义变量。您可以尝试 DECLARE 语句和 SET 语句,如下链接所示:

https://learn.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';

关于azure - 如何将变量传递给 azure devops 管道中的 SqlAzureDacpacDeployment@1 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63344142/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com