SSDT项目的Azure DevOps管道在不需要创建对象时找不到变量

问题描述 投票:0回答:1

我正在使用Azure Devops部署我的SSDT项目。我正在尝试更新具有DATABASE SCOPED CREDENTIALEXTERNAL DATA SOURCE的Azure SQL数据仓库。

我找到了这篇文章,然后执行了这些步骤。 https://techcommunity.microsoft.com/t5/azure-synapse-analytics/how-to-securely-manage-load-credentials-with-ssdt-azure-key/bc-p/1397979

在我的发布管道中,我具有此设置来部署我的SSDT项目。如您所见,我正在使用我的Azure Key Vault中的值。

- task: AzureKeyVault@1
  inputs:
   azureSubscription: '<My Azure Subscription>'
   KeyVaultName: '<My Key Vault>'
   SecretsFilter: '*'
...
- task: SqlAzureDataWarehouseDacpacDeployment@1
  inputs:
    azureSubscription: '<My Azure Subscription>'
    AuthenticationType: 'server'
    ServerName: 'ABC.database.windows.net'
    DataWarehouse: '$(SynapseName)'
    SqlUsername: '$(SynapseSQLUsername)'
    SqlPassword: '$(SynapseSQLPassword)'
    deployType: 'DacpacTask'
    DeploymentAction: 'Publish'
    DacpacFile: 'SQL_ASynapse\bin\Release\SQL_ASynapse.dacpac'
    AdditionalArguments: '/p:IgnoreAnsiNulls=True /p:IgnoreComments=True /v:DatabaseScopeCredentialSecret=$(DatabaseScopeCredentialSecret) /v:DatabaseScopeCredentialIdentity=$(DatabaseScopeCredentialIdentity) /v:ExternalDataSourceMarineTrafficLocation=$(ExternalDataSourceMarineTrafficLocation)'
    IpDetectionMethod: 'AutoDetect'

我正在两个打击脚本中为三个变量传递三个值。

$(DatabaseScopeCredentialSecret)
$(DatabaseScopeCredentialIdentity) 
$(ExternalDataSourceMarineTrafficLocation)

我在下面的代码中包含两个单独的SQL文件。

ADLSCredential.sql:

CREATE MASTER KEY;
GO
CREATE DATABASE SCOPED CREDENTIAL ADLSCredential
WITH
    IDENTITY = '$(DatabaseScopeCredentialIdentity)',
    SECRET = '$(DatabaseScopeCredentialSecret)'
;

AzureDataLakeStoreMarineTraffic.sql:

CREATE EXTERNAL DATA SOURCE AzureDataLakeStoreMarineTraffic
WITH (
    TYPE = HADOOP,
    LOCATION='$(ExternalDataSourceMarineTrafficLocation)', 
    CREDENTIAL = ADLSCredential
);

[当我在DW(Synapse)上没有这些对象时,我的管道可以从Azure密钥保管库中找到值并分配给我的参数并创建两个对象,但是下次我遇到以下错误。

 ##[error]*** Could not deploy package.
 ##[error]Warning SQL72013: The following SqlCmd variables are not defined in the target scripts: DatabaseScopeCredentialSecret DatabaseScopeCredentialIdentity ExternalDataSourceMarineTrafficLocation.
Error SQL72014: .Net SqlClient 

当我不需要运行那些脚本时,通过将值传递给我的参数,SQLCMD找不到这些变量,因为它没有创建它们,因此出现了缝隙。

有什么办法可以在某个地方使用公共变量,或者告诉SQLCMD不要传递秒值?

azure-devops azure-pipelines sql-server-data-tools external-data-source database-scope-credential
1个回答
1
投票

我发现了我遇到的问题。

我忘了在SSDT项目中创建变量。创建它们之后,一切正常。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.