英文:
Task name shows wrong pattern even it matches correctly in the YAML file
问题
下面脚本的任务名称有什么问题:
我正在编写YAML脚本,用于从本地PostgreSQL数据库将数据复制到Azure PostgreSQL DB实例,通过Azure DevOps CI/CD管道,但出现了语法错误。
代码:
pool:
vmImage: ubuntu-latest
stages:
- stage: CopyData
jobs:
- job: CopyDataJob
displayName: '将数据从本地PostgreSQL复制到Azure PostgreSQL'
steps:
- task: PostgreSQLScript@0
displayName: '从本地PostgreSQL导出数据'
inputs:
connectionType: 'PostgreSQL'
postgresqlFile: 'location.sql'
postgresqlConnectionString: 'DATABASE_URL=postgres://{testuser2408}:{testuser2408!}@{localhost}:{5432}/{postgres}'
failOnScriptError: true
- task: CopyFiles@2
displayName: '将导出的数据复制到构建工件暂存目录'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: 'path/to/exported_data/*.csv'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
英文:
What is wrong in the task name of the below script:
I am writing the YAML Script for Data Copy from Local Postgre SQL Database to Azure PostgreSQL DB Instance through Azure DevOps CI/CD Pipelines but getting the syntax error
Code:
pool:
vmImage: ubuntu-latest
stages:
- stage: CopyData
jobs:
- job: CopyDataJob
displayName: 'Copy Data from Local PostgreSQL to Azure PostgreSQL'
steps:
- task: PostgreSQLScript@0
displayName: 'Export Data from Local PostgreSQL'
inputs:
connectionType: 'PostgreSQL'
postgresqlFile: 'location.sql'
postgresqlConnectionString: 'DATABASE_URL=postgres://{testuser2408}:{testuser2408!}@{localhost}:{5432}/{postgres}'
failOnScriptError: true
- task: CopyFiles@2
displayName: 'Copy Exported Data to Artifact Staging Directory'
inputs:
SourceFolder: '$(Build.SourcesDirectory)'
Contents: 'path/to/exported_data/*.csv'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
答案1
得分: 0
发生此错误的原因是没有可用的任务 PostgreSQLScript@0。
要部署到 Azure PostgreSQL 服务器,Microsoft 建议使用 AzureCLI@2 任务
- 任务: AzureCLI@2
显示名称: Azure CLI
输入:
azureSubscription: <Azure 资源管理器服务连接的名称>
scriptLocation: inlineScript
arguments:
-SERVERNAME mydemoserver ``
-DBNAME pollsdb ``
-DBUSER pollsdbuser``
-DBPASSWORD pollsdbpassword
inlineScript: |
az login --allow-no-subscription
az postgres flexible-server execute --name $(SERVERNAME) \
--admin-user $(DBUSER) --admin-password '$(DBPASSWORD)' \
--database-name $(DBNAME) --file-path /code/sql/db-schema-update.sql
英文:
The reason this error is occurring is due to the fact there is no task PostgreSQLScript@0 task available.
For deploying to an Azure PostgreSQL Server Microsoft recommends leveraging the AzureCLI@2 task
- task: AzureCLI@2
displayName: Azure CLI
inputs:
azureSubscription: <Name of the Azure Resource Manager service connection>
scriptLocation: inlineScript
arguments:
-SERVERNAME mydemoserver `
-DBNAME pollsdb `
-DBUSER pollsdbuser`
-DBPASSWORD pollsdbpassword
inlineScript: |
az login --allow-no-subscription
az postgres flexible-server execute --name $(SERVERNAME) \
--admin-user $(DBUSER) --admin-password '$(DBPASSWORD)' \
--database-name $(DBNAME) --file-path /code/sql/db-schema-update.sql
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论