【问题标题】:How to connect the Azure DevOps build pipeline to the private endpoint如何将 Azure DevOps 构建管道连接到专用终结点
【发布时间】:2020-11-18 00:45:58
【问题描述】:

我正在尝试通过 Azure DevOps 构建管道对托管在 Azure App Service 中的 node.js 应用程序执行 mocha 测试。下面是我正在使用的发布管道代码

    # Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- Test

pool:
  vmImage: 'vs2017-win2016'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.14.1'
  displayName: 'Install Node.js'

- script: |
    npm install
- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: 'npm run local

- task: PublishTestResults@2
  condition: succeededOrFailed()
  inputs:
    testRunner: JUnit
    testResultsFiles: 'test-results.xml'

- task: ArchiveFiles@2
  displayName: 'Archive $(System.DefaultWorkingDirectory)'
  inputs:
    rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
    includeRootFolder: false
    archiveFile: '$(Build.ArtifactStagingDirectory)/node.zip'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

当我运行构建时,我收到以下错误

{"name":"xxxx","hostname":"xxxx","pid":xxxx,"level":50,"msg":"Error while connecting sql database xxxx-dev","time":"2020-11-17T11:37:26.852Z","v":0} 
[0] {"name":"xxxxx","hostname":"xxxxxx","pid":xxxx,"level":50,"err":{"message":"Reason: An instance-specific error occurred while establishing a connection to SQL Server. Connection was denied since Deny Public Network Access is set to Yes (https://docs.microsoft.com/azure/azure-sql/database/connectivity-settings#deny-public-network-access). To connect to this server, use the Private Endpoint from inside your virtual network (https://docs.microsoft.com/azure/sql-database/sql-database-private-endpoint-overview#how-to-set-up-private-link-for-azure-sql-database).","name":"ConnectionError","stack":"ConnectionError: Reason: An instance-specific error occurred while establishing a connection to SQL Server. Connection was denied since Deny Public Network Access is set to Yes (
[0] {"name":"xxxx-device-controller","hostname":"xxxxx","pid":xxxx,"level":50,"msg":"Error while attempting to complete call","time":"2020-11-17T11:37:26.852Z","v":0} 

有没有办法直接在App服务中运行测试?或者如何建立连接

【问题讨论】:

  • 您好,这个问题有更新吗?请检查以下答案是否对您有帮助,并随时离开您的 cmets。

标签: node.js azure azure-devops azure-web-app-service mocha.js


【解决方案1】:

为了连接到SQL数据库,IP应该被列入白名单(Set server firewall在数据库的Overview选项卡中。因此你需要构建服务器的IP地址。因为这个IP可以随着每次构建而改变,则需要从管道中添加。

this article 已经讨论了如何做到这一点。您需要稍微修改命令:

  • 将 IP 列入白名单:New-AzureRmSqlServerFirewallRule 而不是 Add-AzWebAppAccessRestrictionRule。您应该能够获取所有必需的参数,请参阅documentation
  • IP 地址将从管道中删除Remove-AzureRmSqlServerFirewallRule

【讨论】:

猜你喜欢
  • 2021-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-24
  • 1970-01-01
  • 1970-01-01
  • 2020-01-30
相关资源
最近更新 更多