azure 任务名称显示错误模式,即使它在YAML文件中正确匹配

vxf3dgd4  于 2023-06-24  发布在  其他
关注(0)|答案(1)|浏览(116)

下面脚本的任务名称有什么错误:

我正在编写YAML脚本,用于通过Azure DevOps CI/CD管道从本地PostgreSQL数据库复制到Azure PostgreSQL DB示例,但得到语法错误

编码

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)'
cyvaqqii

cyvaqqii1#

发生此错误的原因是没有可用的任务PostgreSQL Script@0任务。
要部署到Azure PostgreSQL Server,Microsoft建议利用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

相关问题