我正在使用 Azure Devops 部署我的 SSDT 项目。我正在尝试更新我拥有的 Azure SQL 数据仓库DATABASE SCOPED CREDENTIAL
和EXTERNAL DATA SOURCE
.
我找到了这篇文章,并做了这些步骤。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(突触)上没有这些对象时,我的管道能够从 Azure key Vault 中找到值并分配给我的参数并创建这两个对象,但下次我遇到以下错误。
##[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 不要在第二次传递值?